home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr44 / frasrc19.zip / CMDFILES.C < prev    next >
C/C++ Source or Header  |  1995-03-04  |  89KB  |  2,764 lines

  1. /*
  2.     Command-line / Command-File Parser Routines
  3. */
  4.  
  5. #include <stdlib.h>
  6. #include <stdio.h>
  7. #include <string.h>
  8. #include <float.h>
  9. #include <ctype.h>
  10. #include <time.h>
  11. #include <math.h>
  12. #ifndef XFRACT
  13. #include <bios.h>
  14. #endif
  15. #include "fractint.h"
  16. #include "fractype.h"
  17. /*#ifdef __TURBOC__
  18. #include <dir.h>
  19. #endif  */
  20. #include "prototyp.h"
  21.  
  22. #ifdef XFRACT
  23. #define DEFAULT_PRINTER 5    /* Assume a Postscript printer */
  24. #define PRT_RESOLUTION  100    /* Assume medium resolution    */
  25. #define INIT_GIF87      0    /* Turn on GIF 89a processing  */
  26. #else
  27. #define DEFAULT_PRINTER 2    /* Assume an IBM/Epson printer */
  28. #define PRT_RESOLUTION  60    /* Assume low resolution       */
  29. #define INIT_GIF87      0    /* Turn on GIF 89a processing  */
  30. #endif
  31.  
  32. static int  cmdfile(FILE *,int);
  33. static int  next_command(char *,int,FILE *,char *,int *,int);
  34. static int  next_line(FILE *,char *,int);
  35. int  cmdarg(char *,int);
  36. static void argerror(char *);
  37. static void initvars_run(void);
  38. static void initvars_restart(void);
  39. static void initvars_fractal(void);
  40. static void initvars_3d(void);
  41. static void reset_ifs_defn(void);
  42. static void parse_textcolors(char *value);
  43. static int  parse_colors(char *value);
  44. static int  parse_printer(char *value);
  45. static int  get_bf(bf_t, char *);
  46.  
  47. /* variables defined by the command line/files processor */
  48. int    pseudox=0;        /* xdots to use for video independence */
  49. int    pseudoy=0;        /* ydots to use for video independence */
  50. int     bfdigits=0;            /* digits to use (force) for bf_math */
  51. int    showdot;        /* color to show crawling graphics cursor */
  52. char    temp1[256];        /* temporary strings        */
  53. char    readname[FILE_MAX_PATH];/* name of fractal input file */
  54. char    tempdir[FILE_MAX_DIR] = {""}; /* name of temporary directory */
  55. char    workdir[FILE_MAX_DIR] = {""}; /* name of directory for misc files */
  56. char    gifmask[13] = {""};
  57. char    PrintName[FILE_MAX_PATH]={"fract001.prn"}; /* Name for print-to-file */
  58. char    savename[FILE_MAX_PATH]={"fract001"};  /* save files using this name */
  59. char    autoname[FILE_MAX_PATH]={"auto.key"}; /* record auto keystrokes here */
  60. int    potflag=0;        /* continuous potential enabled? */
  61. int    pot16bit;        /* store 16 bit continuous potential values */
  62. int    gif87a_flag;        /* 1 if GIF87a format, 0 otherwise */
  63. int     dither_flag;        /* 1 if want to dither GIFs */
  64. int    askvideo;        /* flag for video prompting */
  65. char    floatflag;
  66. int    biomorph;        /* flag for biomorph */
  67. int    usr_biomorph;
  68. int    forcesymmetry;        /* force symmetry */
  69. int    showfile;        /* zero if file display pending */
  70. int    rflag, rseed;        /* Random number seeding flag and value */
  71. int    decomp[2];        /* Decomposition coloring */
  72. int    distest;
  73. int    distestwidth;
  74. char     overwrite = 0;    /* 0 if file overwrite not allowed */
  75. int    soundflag;        /* 0 if sound is off, 1 if on */
  76. int    basehertz;        /* sound=x/y/x hertz value */
  77. int    debugflag;        /* internal use only - you didn't see this */
  78. int    timerflag;        /* you didn't see this, either */
  79. int    cyclelimit;        /* color-rotator upper limit */
  80. int    inside;         /* inside color: 1=blue     */
  81. int    fillcolor;         /* fillcolor: -1=normal     */
  82. int    outside;        /* outside color    */
  83. int    finattract;        /* finite attractor logic */
  84. int    display3d;        /* 3D display flag: 0 = OFF */
  85. int    overlay3d;        /* 3D overlay flag: 0 = OFF */
  86. int    init3d[20];        /* '3d=nn/nn/nn/...' values */
  87. int    initbatch;        /* 1 if batch run (no kbd)  */
  88. int    initsavetime;        /* autosave minutes        */
  89. _CMPLX  initorbit;        /* initial orbitvalue */
  90. char    useinitorbit;        /* flag for initorbit */
  91. int    initmode;        /* initial video mode        */
  92. int    initcyclelimit;     /* initial cycle limit        */
  93. BYTE usemag;            /* use center-mag corners   */
  94. long    bailout;        /* user input bailout value */
  95. enum bailouts bailoutest;    /* test used for determining bailout */
  96. double    inversion[3];        /* radius, xcenter, ycenter */
  97. int    rotate_lo,rotate_hi;    /* cycling color range        */
  98. int far *ranges;        /* iter->color ranges mapping */
  99. int    rangeslen = 0;        /* size of ranges array     */
  100. BYTE far *mapdacbox = NULL;    /* map= (default colors)    */
  101. int    colorstate;        /* 0, dacbox matches default (bios or map=) */
  102.                 /* 1, dacbox matches no known defined map   */
  103.                 /* 2, dacbox matches the colorfile map        */
  104. int    colorpreloaded;     /* if dacbox preloaded for next mode select */
  105. int     save_release;        /* release creating PAR file*/
  106. char    dontreadcolor=0;    /* flag for reading color from GIF */
  107.  
  108. int Targa_Out = 0;
  109. char    colorfile[FILE_MAX_PATH];/* from last <l> <s> or colors=@filename */
  110. int functionpreloaded; /* if function loaded for new bifs, JCO 7/5/92 */
  111. float    screenaspect = DEFAULTASPECT;    /* aspect ratio of the screen */
  112.  
  113. /* TARGA+ variables */
  114. int    TPlusFlag;        /* Use the TARGA+ if found  */
  115. int    MaxColorRes;        /* Default Color Resolution if available */
  116. int    PixelZoom;        /* TPlus Zoom Level */
  117. int    NonInterlaced;        /* Non-Interlaced video flag */
  118.  
  119. int    orbitsave = 0;        /* for IFS and LORENZ to output acrospin file */
  120. int orbit_delay;                /* clock ticks delating orbit release */
  121. int    transparent[2];     /* transparency min/max values */
  122. int    LogFlag;        /* Logarithmic palette flag: 0 = no */
  123.  
  124. BYTE exitmode = 3;    /* video mode on exit */
  125.  
  126. char    ai_8514;    /* Flag for using 8514a afi JCO 4/11/92 */
  127.  
  128. int        bios_palette;        /* set to 1 to force BIOS palette updates */
  129. int        escape_exit;         /* set to 1 to avoid the "are you sure?" screen */
  130. int first_init=1;        /* first time into cmdfiles? */
  131. static int init_rseed;
  132. static char initcorners,initparams;
  133. struct fractalspecificstuff far *curfractalspecific;
  134.  
  135. char FormFileName[FILE_MAX_PATH];/* file to find (type=)formulas in */
  136. char FormName[ITEMNAMELEN+1];    /* Name of the Formula (if not null) */
  137. char LFileName[FILE_MAX_PATH];   /* file to find (type=)L-System's in */
  138. char LName[ITEMNAMELEN+1];     /* Name of L-System */
  139. char CommandFile[FILE_MAX_PATH]; /* file to find command sets in */
  140. char CommandName[ITEMNAMELEN+1]; /* Name of Command set */
  141. char CommandComment1[57];     /* comments for command set */
  142. char CommandComment2[57];
  143. char CommandComment3[57];
  144. char CommandComment4[57];
  145. char IFSFileName[FILE_MAX_PATH];/* file to find (type=)IFS in */
  146. char IFSName[ITEMNAMELEN+1];    /* Name of the IFS def'n (if not null) */
  147. float far *ifs_defn = NULL;    /* ifs parameters */
  148. int  ifs_type;            /* 0=2d, 1=3d */
  149. int  slides = 0;        /* 1 autokey=play, 2 autokey=record */
  150.  
  151. BYTE txtcolor[]={
  152.       BLUE*16+L_WHITE,      /* C_TITLE           title background */
  153.       BLUE*16+L_GREEN,      /* C_TITLE_DEV       development vsn foreground */
  154.       GREEN*16+YELLOW,      /* C_HELP_HDG        help page title line */
  155.       WHITE*16+BLACK,      /* C_HELP_BODY       help page body */
  156.       GREEN*16+GRAY,      /* C_HELP_INSTR      help page instr at bottom */
  157.       WHITE*16+BLUE,      /* C_HELP_LINK       help page links */
  158.       CYAN*16+BLUE,      /* C_HELP_CURLINK    help page current link */
  159.       WHITE*16+GRAY,      /* C_PROMPT_BKGRD    prompt/choice background */
  160.       WHITE*16+BLACK,      /* C_PROMPT_TEXT     prompt/choice extra info */
  161.       BLUE*16+WHITE,      /* C_PROMPT_LO       prompt/choice text */
  162.       BLUE*16+L_WHITE,      /* C_PROMPT_MED      prompt/choice hdg2/... */
  163.       BLUE*16+YELLOW,      /* C_PROMPT_HI       prompt/choice hdg/cur/... */
  164.       GREEN*16+L_WHITE,   /* C_PROMPT_INPUT    fullscreen_prompt input */
  165.       CYAN*16+L_WHITE,      /* C_PROMPT_CHOOSE   fullscreen_prompt choice */
  166.       MAGENTA*16+L_WHITE, /* C_CHOICE_CURRENT  fullscreen_choice input */
  167.       BLACK*16+WHITE,      /* C_CHOICE_SP_INSTR speed key bar & instr */
  168.       BLACK*16+L_MAGENTA, /* C_CHOICE_SP_KEYIN speed key value */
  169.       WHITE*16+BLUE,      /* C_GENERAL_HI      tab, thinking, IFS */
  170.       WHITE*16+BLACK,      /* C_GENERAL_MED */
  171.       WHITE*16+GRAY,      /* C_GENERAL_LO */
  172.       BLACK*16+L_WHITE,   /* C_GENERAL_INPUT */
  173.       WHITE*16+BLACK,      /* C_DVID_BKGRD      disk video */
  174.       BLACK*16+YELLOW,      /* C_DVID_HI */
  175.       BLACK*16+L_WHITE,   /* C_DVID_LO */
  176.       RED*16+L_WHITE,      /* C_STOP_ERR        stop message, error */
  177.       GREEN*16+BLACK,      /* C_STOP_INFO       stop message, info */
  178.       BLUE*16+WHITE,      /* C_TITLE_LOW       bottom lines of title screen */
  179.       GREEN*16+BLACK,      /* C_AUTHDIV1        title screen dividers */
  180.       GREEN*16+GRAY,      /* C_AUTHDIV2        title screen dividers */
  181.       BLACK*16+L_WHITE,   /* C_PRIMARY           primary authors */
  182.       BLACK*16+WHITE      /* C_CONTRIB           contributing authors */
  183.       };
  184.  
  185. /* start of string literals cleanup */
  186. char s_atan[]    = "atan";
  187. char s_iter[]    = "iter";
  188. char s_real[]    = "real";
  189. char s_mult[]     = "mult";
  190. char s_sum[]     = "summ";
  191. char s_imag[]    = "imag";
  192. char s_zmag[]    = "zmag";
  193. char s_bof60[]   = "bof60";
  194. char s_bof61[]   = "bof61";
  195. char s_maxiter[] =  "maxiter";
  196. char s_epscross[] =  "epsiloncross";
  197. char s_startrail[] =  "startrail";
  198. char s_normal[] =  "normal";
  199. char s_period[] = "period";
  200. char s_or[]     = "or";
  201. char s_and[]    = "and";
  202. char s_mod[]    = "mod";
  203. char s_16bit[] =            "16bit";
  204. char s_387[] =              "387";
  205. char s_3d[] =               "3d";
  206. char s_3dmode[] =           "3dmode";
  207. char s_adapter[] =          "adapter";
  208. char s_afi[] =              "afi";
  209. char s_ambient[] =          "ambient";
  210. char s_askvideo[] =         "askvideo";
  211. char s_autokey[] =          "autokey";
  212. char s_autokeyname[] =      "autokeyname";
  213. char s_background[] =       "background";
  214. char s_bailout[] =          "bailout";
  215. char s_bailoutest[] =       "bailoutest";
  216. char s_batch[] =            "batch";
  217. char s_biomorph[] =         "biomorph";
  218. char s_biospalette[] =      "biospalette";
  219. char s_brief[] =            "brief";
  220. char s_bright[] =           "bright";
  221. char s_centermag[] =        "center-mag";
  222. char s_cga[] =              "cga";
  223. char s_coarse[] =           "coarse";
  224. char s_colorps[] =          "colorps";
  225. char s_colors[] =           "colors";
  226. char s_comport[] =          "comport";
  227. char s_converge[] =         "converge";
  228. char s_corners[] =          "corners";
  229. char s_cr[] =               "cr";
  230. char s_crlf[] =             "crlf";
  231. char s_crop[] =             "crop";
  232. char s_cyclelimit[] =       "cyclelimit";
  233. char s_cyclerange[] =       "cyclerange";
  234. char s_debug[] =            "debug";
  235. char s_debugflag[] =        "debugflag";
  236. char s_decomp[] =           "decomp";
  237. char s_distest[] =          "distest";
  238. char s_dither[] =           "dither";
  239. char s_ega[] =              "ega";
  240. char s_egamono[] =          "egamono";
  241. char s_epsf[] =             "epsf";
  242. char s_exitmode[] =         "exitmode";
  243. char s_exitnoask[] =        "exitnoask";
  244. char s_filename[] =         "filename";
  245. char s_fillcolor[] =        "fillcolor";
  246. char s_filltype[] =         "filltype";
  247. char s_finattract[] =       "finattract";
  248. char s_float[] =            "float";
  249. char s_formulafile[] =      "formulafile";
  250. char s_formulaname[] =      "formulaname";
  251. char s_fpu[] =              "fpu";
  252. char s_fract001prn[] =     "fract001.prn";
  253. char s_fullcolor[] =        "fullcolor";
  254. char s_function[] =         "function";
  255. char s_gif87a[] =           "gif87a";
  256. char s_halftone[] =         "halftone";
  257. char s_haze[] =             "haze";
  258. char s_hertz[] =            "hertz";
  259. char s_hgc[] =              "hgc";
  260. char s_ifs[] =              "ifs";
  261. char s_ifs3d[] =            "ifs3d";
  262. char s_ifsfile[] =          "ifsfile";
  263. char s_iit[] =              "iit";
  264. char s_initorbit[] =        "initorbit";
  265. char s_inside[] =           "inside";
  266. char s_interocular[] =      "interocular";
  267. char s_invert[] =           "invert";
  268. char s_iterincr[] =         "iterincr";
  269. char s_julibrot3d[] =       "julibrot3d";
  270. char s_julibroteyes[] =     "julibroteyes";
  271. char s_julibrotfromto[] =   "julibrotfromto";
  272. char s_latitude[] =         "latitude";
  273. char s_lf[] =               "lf";
  274. char s_lfile[] =            "lfile";
  275. char s_lightname[] =        "lightname";
  276. char s_lightsource[] =      "lightsource";
  277. char s_linefeed[] =         "linefeed";
  278. char s_lname[] =            "lname";
  279. char s_logmap[] =           "logmap";
  280. char s_longitude[] =        "longitude";
  281. char s_makedoc[] =          "makedoc";
  282. char s_makemig[] =          "makemig";
  283. char s_map[] =              "map";
  284. char s_maxcolorres[] =      "maxcolorres";
  285. char s_mcga[] =             "mcga";
  286. char s_miim[] =             "miim";
  287. char s_mono[] =             "mono";
  288. char s_noiit[] =            "noiit";
  289. char s_none[] =             "none";
  290. char s_noninterlaced[] =    "noninterlaced";
  291. char s_olddemmcolors[] =    "olddemmcolors";
  292. char s_orbitdelay[] =       "orbitdelay";
  293. char s_orbitname[] =        "orbitname";
  294. char s_orbitsave[] =        "orbitsave";
  295. char s_origin[] =           "origin";
  296. char s_outside[] =          "outside";
  297. char s_overlay[] =          "overlay";
  298. char s_overwrite[] =        "overwrite";
  299. char s_params[] =           "params";
  300. char s_parmfile[] =         "parmfile";
  301. char s_passes[] =           "passes";
  302. char s_periodicity[] =      "periodicity";
  303. char s_perspective[] =      "perspective";
  304. char s_pi[] =               "pi";
  305. char s_pixel[] =            "pixel";
  306. char s_pixelzoom[] =        "pixelzoom";
  307. char s_play[] =             "play";
  308. char s_plotstyle[] =        "plotstyle";
  309. char s_potential[] =        "potential";
  310. char s_preview[] =          "preview";
  311. char s_printer[] =          "printer";
  312. char s_printfile[] =        "printfile";
  313. char s_radius[] =           "radius";
  314. char s_ramvideo[] =         "ramvideo";
  315. char s_randomize[] =        "randomize";
  316. char s_ranges[] =           "ranges";
  317. char s_ray[] =              "ray";
  318. char s_record[] =           "record";
  319. char s_release[] =          "release";
  320. char s_reset[] =            "reset";
  321. char s_rleps[] =            "rleps";
  322. char s_rotation[] =         "rotation";
  323. char s_roughness[] =        "roughness";
  324. char s_rseed[] =            "rseed";
  325. char s_savename[] =         "savename";
  326. char s_savetime[] =         "savetime";
  327. char s_scalexyz[] =         "scalexyz";
  328. char s_showbox[] =          "showbox";
  329. char s_showdot[] =          "showdot";
  330. char s_smoothing[] =        "smoothing";
  331. char s_sound[] =            "sound";
  332. char s_sphere[] =           "sphere";
  333. char s_stereo[] =           "stereo";
  334. char s_symmetry[] =         "symmetry";
  335. char s_targa_out[] =        "targa_out";
  336. char s_tempdir[] =          "tempdir";
  337. char s_workdir[] =          "workdir";
  338. char s_usegrayscale[] =     "usegrayscale";
  339. char s_monitorwidth[] =     "monitorwidth";
  340. char s_targa_overlay[] =    "targa_overlay";
  341. char s_textcolors[] =       "textcolors";
  342. char s_textsafe[] =         "textsafe";
  343. char s_title[] =            "title";
  344. char s_tplus[] =            "tplus";
  345. char s_translate[] =        "translate";
  346. char s_transparent[] =      "transparent";
  347. char s_type[] =             "type";
  348. char s_vesadetect[] =       "vesadetect";
  349. char s_vga[] =              "vga";
  350. char s_video[] =            "video";
  351. char s_viewwindows[] =      "viewwindows";
  352. char s_warn[] =             "warn";
  353. char s_waterline[] =        "waterline";
  354. char s_xaxis[] =            "xaxis";
  355. char s_xyadjust[] =         "xyadjust";
  356. char s_xyaxis[] =           "xyaxis";
  357. char s_xyshift[] =          "xyshift";
  358. char s_yaxis [] =              "yaxis"; 
  359. char s_sin [] =             "sin";
  360. char s_sinh [] =            "sinh";
  361. char s_cos [] =             "cos"; 
  362. char s_cosh [] =            "cosh";
  363. char s_sqr [] =             "sqr"; 
  364. char s_log [] =             "log"; 
  365. char s_exp [] =             "exp"; 
  366. char s_abs [] =             "abs"; 
  367. char s_conj [] =            "conj";
  368. char s_fn1 [] =             "fn1"; 
  369. char s_fn2 [] =             "fn2"; 
  370. char s_fn3 [] =             "fn3"; 
  371. char s_fn4 [] =             "fn4"; 
  372. char s_flip [] =            "flip";
  373. char s_tan [] =             "tan"; 
  374. char s_tanh [] =            "tanh";
  375. char s_cotan [] =           "cotan";
  376. char s_cotanh [] =          "cotanh";
  377. char s_cosxx [] =           "cosxx";
  378. char s_srand [] =           "srand";
  379. char s_recip [] =           "recip";
  380. char s_ident [] =           "ident";
  381. char s_zero [] =            "zero";
  382. char s_asin [] =            "asin";
  383. char s_asinh [] =            "asinh";
  384. char s_acos [] =            "acos";
  385. char s_acosh [] =           "acosh";
  386. char s_atanh [] =           "atanh";
  387. char s_cabs [] =            "cabs";
  388. char s_sqrt [] =            "sqrt";
  389. char s_bfdigits [] =        "bfdigits";
  390.  
  391. static char s_sstoolsini [] =  "sstools.ini";
  392. static char s_fractintfrm [] = "fractint.frm";
  393. static char s_fractintl [] =   "fractint.l";
  394. static char s_fractintpar [] = "fractint.par";
  395. static char s_fractintifs [] = "fractint.ifs";
  396. static char s_commandline [] = "command line";
  397. static char s_at_cmd [] =      "PAR file";
  398.  
  399. char far s_escapetoabort[] = "Press Escape to abort, any other key to continue";
  400. char far s_pressanykeytocontinue[] = "press any key to continue";
  401.     
  402. /*
  403.     cmdfiles(argc,argv) process the command-line arguments
  404.         it also processes the 'sstools.ini' file and any
  405.         indirect files ('fractint @myfile')
  406. */
  407.  
  408. /* This probably ought to go somewhere else, but it's used here.        */
  409. /* getpower10(x) returns the magnitude of x.  This rounds               */
  410. /* a little so 9.95 rounds to 10, but we're using a binary base anyway, */
  411. /* so there's nothing magic about changing to the next power of 10.     */
  412. int getpower10(LDBL x)
  413. {
  414.     char string[11]; /* space for "+x.xe-xxxx" */
  415.     int p;
  416.  
  417. #ifdef USE_LONG_DOUBLE
  418.     sprintf(string,"%+.1Le", x);
  419. #else
  420.     sprintf(string,"%+.1le", x);
  421. #endif
  422.     p = atoi(string+5);
  423.     return p;
  424. }
  425.  
  426.  
  427.  
  428. int cmdfiles(int argc,char **argv)
  429. {
  430.    int       i;
  431.    char    curarg[141];
  432.    char    tempstring[101];
  433.    char    *sptr;
  434.    FILE    *initfile;
  435.  
  436.    if (first_init) initvars_run();    /* once per run initialization */
  437.    initvars_restart();            /* <ins> key initialization */
  438.    initvars_fractal();            /* image initialization */
  439.  
  440.    findpath(s_sstoolsini, tempstring); /* look for SSTOOLS.INI */
  441.    if (tempstring[0] != 0)        /* found it! */
  442.       if ((initfile = fopen(tempstring,"r")) != NULL)
  443.      cmdfile(initfile,1);        /* process it */
  444.  
  445.    for (i = 1; i < argc; i++) {     /* cycle through args */
  446. #ifdef XFRACT
  447.       /* Let the xfract code take a look at the argument */
  448.       if (unixarg(argc,argv,&i)) continue;
  449. #endif
  450.       strcpy(curarg,argv[i]);
  451.       if (curarg[0] == ';')             /* start of comments? */
  452.      break;
  453.       if (curarg[0] != '@') {           /* simple command? */
  454.      if (strchr(curarg,'=') == NULL) { /* not xxx=yyy, so check for gif */
  455.         strcpy(tempstring,curarg);
  456.         if (strchr(curarg,'.') == NULL)
  457.            strcat(tempstring,".gif");
  458.         if ((initfile = fopen(tempstring,"rb")) != NULL) {
  459.            fread(tempstring,6,1,initfile);
  460.            if ( tempstring[0] == 'G'
  461.          && tempstring[1] == 'I'
  462.          && tempstring[2] == 'F'
  463.          && tempstring[3] >= '8' && tempstring[3] <= '9'
  464.          && tempstring[4] >= '0' && tempstring[4] <= '9') {
  465.           strcpy(readname,curarg);
  466.           extract_filename(browsename,readname);
  467.           curarg[0] = (char)(showfile = 0);
  468.           }
  469.            fclose(initfile);
  470.            }
  471.         }
  472.      if (curarg[0])
  473.         cmdarg(curarg,0);        /* process simple command */
  474.      }
  475.       else if ((sptr = strchr(curarg,'/')) != NULL) { /* @filename/setname? */
  476.      *sptr = 0;
  477.          if(merge_pathnames(CommandFile, &curarg[1], 0) < 0)
  478.             init_msg(0,"",CommandFile,0);
  479.      strcpy(CommandName,sptr+1);
  480.      if(find_file_item(CommandFile,CommandName,&initfile)<0 || initfile==NULL)
  481.         argerror(curarg);
  482.      cmdfile(initfile,3);
  483.      }
  484.       else {                /* @filename */
  485.      if ((initfile = fopen(&curarg[1],"r")) == NULL)
  486.         argerror(curarg);
  487.      cmdfile(initfile,0);
  488.      }
  489.       }
  490.  
  491.    if (first_init == 0) {
  492.       initmode = -1; /* don't set video when <ins> key used */
  493.       showfile = 1;  /* nor startup image file            */
  494.       }
  495.  
  496.    init_msg(0,"",NULL,0);  /* this causes getakey if init_msg called on runup */
  497.  
  498.    if(debugflag != 110)
  499.        first_init = 0;
  500. /*     {
  501.         char msg[80];
  502.         sprintf(msg,"cmdfiles colorpreloaded %d showfile %d savedac %d",
  503.             colorpreloaded, showfile, savedac);
  504.         stopmsg(0,msg);
  505.      }
  506. */     
  507.    if(colorpreloaded && showfile==0) /* PAR reads a file and sets color */
  508.       dontreadcolor = 1;   /* don't read colors from GIF */
  509.    else
  510.       dontreadcolor = 0;   /* read colors from GIF */    
  511.    return(0);
  512. }
  513.  
  514.  
  515. int load_commands(FILE *infile)
  516. {
  517.    /* when called, file is open in binary mode, positioned at the */
  518.    /* '(' or '{' following the desired parameter set's name       */
  519.    int ret;
  520.    initcorners = initparams = 0; /* reset flags for type= */
  521.    ret = cmdfile(infile,2);
  522. /*     
  523.      {
  524.         char msg[80];
  525.         sprintf(msg,"load commands colorpreloaded %d showfile %d savedac %d",
  526.             colorpreloaded, showfile, savedac);
  527.         stopmsg(0,msg);
  528.      }
  529. */     
  530.  
  531.    if(colorpreloaded && showfile==0) /* PAR reads a file and sets color */
  532.       dontreadcolor = 1;   /* don't read colors from GIF */
  533.    else
  534.       dontreadcolor = 0;   /* read colors from GIF */    
  535.    return ret;
  536. }
  537.  
  538.  
  539. static void initvars_run()        /* once per run init */
  540. {
  541.    char *p;
  542.    init_rseed = (int)time(NULL);
  543.    if((p = getenv("TMP")) == NULL)
  544.       p = getenv("TEMP");
  545.    if(p != NULL)
  546.    {
  547.       if(isadirectory(p) != 0)
  548.       {
  549.          strcpy(tempdir,p);
  550.          fix_dirname(tempdir);
  551.       }   
  552.    }
  553.    else
  554.       *tempdir = 0;  
  555. }
  556.  
  557. static void initvars_restart()        /* <ins> key init */
  558. {
  559.    save_release = release;              /* this release number */
  560.    gif87a_flag = INIT_GIF87;            /* turn on GIF89a processing */
  561.    dither_flag = 0;            /* no dithering */
  562.    askvideo = 1;            /* turn on video-prompt flag */
  563.    overwrite = 0;            /* don't overwrite           */
  564.    soundflag = -1;            /* sound is on             */
  565.    basehertz = 440;            /* basic hertz rate         */
  566.    initbatch = 0;            /* not in batch mode         */
  567.    initsavetime = 0;            /* no auto-save          */
  568.    initmode = -1;            /* no initial video mode     */
  569.    viewwindow = 0;            /* no view window         */
  570.    viewreduction = (float)4.2;
  571.    viewcrop = 1;
  572.    ai_8514 = 0;                         /* no need for the 8514 API  */
  573.    finalaspectratio = screenaspect;
  574.    viewxdots = viewydots = 0;
  575.    orbit_delay = 0;                     /* full speed orbits */
  576.    debugflag = 0;            /* debugging flag(s) are off */
  577.    timerflag = 0;            /* timer flags are off         */
  578.    far_strcpy(FormFileName,s_fractintfrm); /* default formula file      */
  579.    FormName[0] = 0;
  580.    far_strcpy(LFileName,s_fractintl);
  581.    LName[0] = 0;
  582.    far_strcpy(CommandFile,s_fractintpar);
  583.    CommandName[0] = CommandComment1[0] = CommandComment2[0] = 0;
  584.    CommandComment3[0] = CommandComment4[0] = 0;
  585.    far_strcpy(IFSFileName,s_fractintifs);
  586.    IFSName[0] = 0;
  587.    reset_ifs_defn();
  588.    rflag = 0;                /* not a fixed srand() seed */
  589.    rseed = init_rseed;
  590.    strcpy(readname,DOTSLASH);           /* initially current directory */
  591.    showfile = 1;
  592.    /* next should perhaps be fractal re-init, not just <ins> ? */
  593.    initcyclelimit=55;            /* spin-DAC default speed limit */
  594.    mapset = 0;                /* no map= name active */
  595.    if (mapdacbox) {
  596.       farmemfree(mapdacbox);
  597.       mapdacbox = NULL;
  598.       }
  599.    TPlusFlag = 1;
  600.    MaxColorRes = 8;
  601.    PixelZoom = 0;
  602.    NonInterlaced = 0;
  603.  
  604.    Printer_Type = DEFAULT_PRINTER;      /* assume an IBM/EPSON    */
  605.    Printer_Resolution = PRT_RESOLUTION; /* assume low resolution  */
  606.    Printer_Titleblock = 0;        /* assume no title block  */
  607.    Printer_ColorXlat = 0;        /* assume positive image  */
  608.    Printer_SetScreen = 0;               /* assume default screen  */
  609.    Printer_SFrequency = 45;             /* New screen frequency K */
  610.    Printer_SAngle = 45;                 /* New screen angle     K */
  611.    Printer_SStyle = 1;                  /* New screen style     K */
  612.    Printer_RFrequency = 45;             /* New screen frequency R */
  613.    Printer_RAngle = 75;                 /* New screen angle     R */
  614.    Printer_RStyle = 1;                  /* New screen style     R */
  615.    Printer_GFrequency = 45;             /* New screen frequency G */
  616.    Printer_GAngle = 15;                 /* New screen angle     G */
  617.    Printer_GStyle = 1;                  /* New screen style     G */
  618.    Printer_BFrequency = 45;             /* New screen frequency B */
  619.    Printer_BAngle = 0;                  /* New screen angle     B */
  620.    Printer_BStyle = 1;                  /* New screen style     B */
  621. #ifndef XFRACT
  622.    Print_To_File = 0;                   /* No print-to-file       */
  623.    Printer_CRLF = 0;                    /* Assume CR+LF           */
  624. #else
  625.    Print_To_File = 1;                   /* Print-to-file          */
  626.    Printer_CRLF = 2;                    /* Assume LF              */
  627.    Printer_Compress = 0;                /* Assume NO PostScript compression */
  628. #endif
  629.    EPSFileType = 0;            /* Assume no save to .EPS */
  630.    LPTNumber = 1;            /* assume LPT1 */
  631.    ColorPS = 0;                         /* Assume NO Color PostScr*/
  632.    major_method = breadth_first;    /* default inverse julia methods */
  633.    minor_method = left_first;    /* default inverse julia methods */
  634. }
  635.  
  636. static void initvars_fractal()        /* init vars affecting calculation */
  637. {
  638.    int i;
  639.    bios_palette = 0;                    /* don't force use of a BIOS palette */
  640.    escape_exit = 0;                     /* don't disable the "are you sure?" screen */
  641.    usr_periodicitycheck = 1;        /* turn on periodicity      */
  642.    inside = 1;                /* inside color = blue      */
  643.    fillcolor = -1;            /* no special fill color */
  644.    usr_biomorph = -1;            /* turn off biomorph flag */
  645.    outside = -1;            /* outside color = -1 (not used) */
  646.    maxit = 150;             /* initial maxiter      */
  647.    usr_stdcalcmode = 'g';               /* initial solid-guessing */
  648. #ifndef XFRACT
  649.    usr_floatflag = 0;            /* turn off the float flag */
  650. #else
  651.    usr_floatflag = 1;            /* turn on the float flag */
  652. #endif
  653.    finattract = 0;            /* disable finite attractor logic */
  654.    fractype = 0;            /* initial type Set flag  */
  655.    curfractalspecific = &fractalspecific[0];
  656.    initcorners = initparams = 0;
  657.    bailout = 0;             /* no user-entered bailout */
  658.    useinitorbit = 0;
  659.    for (i = 0; i < MAXPARAMS; i++) param[i] = 0.0;     /* initial parameter values */
  660.    for (i = 0; i < 3; i++) potparam[i]    = 0.0; /* initial potential values */
  661.    for (i = 0; i < 3; i++) inversion[i] = 0.0;    /* initial invert values */
  662.    initorbit.x = initorbit.y = 0.0;    /* initial orbit values */
  663.    invert = 0;
  664.    decomp[0] = decomp[1] = 0;
  665.    usr_distest = 0;
  666.    pseudox = 0;
  667.    pseudoy = 0;
  668.    distestwidth = 71;
  669.    forcesymmetry = 999;         /* symmetry not forced */
  670.    xx3rd = xxmin = -2.5; xxmax = 1.5;    /* initial corner values  */
  671.    yy3rd = yymin = -1.5; yymax = 1.5;    /* initial corner values  */
  672.    bf_math = 0;
  673.    pot16bit = potflag = 0;
  674.    LogFlag = 0;             /* no logarithmic palette */
  675.    set_trig_array(0,s_sin);             /* trigfn defaults */
  676.    set_trig_array(1,s_sqr);
  677.    set_trig_array(2,s_sinh);
  678.    set_trig_array(3,s_cosh);
  679.    if (rangeslen) {
  680.       farmemfree((char far *)ranges);
  681.       rangeslen = 0;
  682.       }
  683.    usemag = 0;                /* use corners, not center-mag */
  684.  
  685.    colorstate = colorpreloaded = 0;
  686.    rotate_lo = 1; rotate_hi = 255;    /* color cycling default range */
  687.  
  688.    display3d = 0;            /* 3D display is off        */
  689.    overlay3d = 0;            /* 3D overlay is off        */
  690.  
  691.    old_demm_colors = 0;
  692.    bailoutest    = Mod;
  693.    floatbailout  = (int (near *)(void))fpMODbailout;
  694.    longbailout   = (int (near *)(void))asmlMODbailout;
  695.    bignumbailout = (int (near *)(void))bnMODbailout;
  696.    bigfltbailout = (int (near *)(void))bfMODbailout;
  697.  
  698.    functionpreloaded = 0; /* for old bifs  JCO 7/5/92 */
  699.    mxminfp = -.83;
  700.    myminfp = -.25;
  701.    mxmaxfp = -.83;
  702.    mymaxfp =  .25;
  703.    originfp = 8;
  704.    heightfp = 7;
  705.    widthfp = 10;
  706.    distfp = 24;
  707.    eyesfp = (float)2.5;
  708.    depthfp = 8;
  709.    neworbittype = JULIA;
  710.    zdots = 128;
  711.    initvars_3d();
  712. }
  713.  
  714. static void initvars_3d()        /* init vars affecting 3d */
  715. {
  716.    RAY     = 0;
  717.    BRIEF   = 0;
  718.    SPHERE = FALSE;
  719.    preview = 0;
  720.    showbox = 0;
  721.    xadjust = 0;
  722.    yadjust = 0;
  723.    eyeseparation = 0;
  724.    glassestype = 0;
  725.    previewfactor = 20;
  726.    red_crop_left   = 4;
  727.    red_crop_right  = 0;
  728.    blue_crop_left  = 0;
  729.    blue_crop_right = 4;
  730.    red_bright      = 80;
  731.    blue_bright     = 100;
  732.    transparent[0] = transparent[1] = 0; /* no min/max transparency */
  733.    set_3d_defaults();
  734. }
  735.  
  736. static void reset_ifs_defn()
  737. {
  738.    if (ifs_defn) {
  739.       farmemfree((char far *)ifs_defn);
  740.       ifs_defn = NULL;
  741.       }
  742. }
  743.  
  744.  
  745. static int cmdfile(FILE *handle,int mode)
  746.    /* mode = 0 command line @filename          */
  747.    /*         1 sstools.ini              */
  748.    /*         2 <@> command after startup      */
  749.    /*         3 command line @filename/setname */
  750. {
  751.    /* note that cmdfile could be open as text OR as binary */
  752.    /* binary is used in @ command processing for reasonable speed note/point */
  753.    int i;
  754.    int lineoffset = 0;
  755.    int changeflag = 0; /* &1 fractal stuff chgd, &2 3d stuff chgd */
  756.    char linebuf[513],*cmdbuf;
  757.    char far *savesuffix;
  758.    /* use near array suffix for large argument buffer, but save existing
  759.       contents to extraseg */
  760.    cmdbuf = (char *)suffix;
  761.    savesuffix = MK_FP(extraseg,0);
  762.    far_memcpy(savesuffix,suffix,10000);
  763.    far_memset(suffix,0,10000);
  764.  
  765.    if (mode == 2 || mode == 3) {
  766.       while ((i = getc(handle)) != '{' && i != EOF) { }
  767.       CommandComment1[0] = CommandComment2[0] = 0;
  768.       CommandComment3[0] = CommandComment4[0] = 0;
  769.       }
  770.    linebuf[0] = 0;
  771.    while (next_command(cmdbuf,10000,handle,linebuf,&lineoffset,mode) > 0) {
  772.       if ((mode == 2 || mode == 3) && strcmp(cmdbuf,"}") == 0) break;
  773.       if ((i = cmdarg(cmdbuf,mode)) < 0) break;
  774.       changeflag |= i;
  775.       }
  776.    fclose(handle);
  777. #ifdef XFRACT
  778.    initmode = 0;        /* Skip credits if @file is used. */
  779. #endif
  780.    far_memcpy(suffix,savesuffix,10000);
  781.    if(changeflag&1)
  782.    {
  783.       backwards_v18();
  784.       backwards_v19();
  785.    }
  786.    return changeflag;
  787. }
  788.  
  789. static int next_command(char *cmdbuf,int maxlen,
  790.               FILE *handle,char *linebuf,int *lineoffset,int mode)
  791. {
  792.    int cmdlen = 0;
  793.    char *lineptr;
  794.    lineptr = linebuf + *lineoffset;
  795.    for(;;) {
  796.       while (*lineptr <= ' ' || *lineptr == ';') {
  797.      if (cmdlen) {            /* space or ; marks end of command */
  798.         cmdbuf[cmdlen] = 0;
  799.         *lineoffset = lineptr - linebuf;
  800.         return cmdlen;
  801.         }
  802.      while (*lineptr && *lineptr <= ' ')
  803.         ++lineptr;            /* skip spaces and tabs */
  804.      if (*lineptr == ';' || *lineptr == 0) {
  805.         if (*lineptr == ';'
  806.           && (mode == 2 || mode == 3)
  807.           && (CommandComment1[0] == 0 || CommandComment2[0] == 0 ||
  808.               CommandComment3[0] == 0 || CommandComment4[0] == 0)) {
  809.            /* save comment */
  810.            while (*(++lineptr)
  811.          && (*lineptr == ' ' || *lineptr == '\t')) { }
  812.            if (*lineptr) {
  813.           if (strlen(lineptr) > 56)
  814.              *(lineptr+56) = 0;
  815.           if (CommandComment1[0] == 0)
  816.              far_strcpy(CommandComment1,lineptr);
  817.           else if (CommandComment2[0] == 0)
  818.              far_strcpy(CommandComment2,lineptr);
  819.           else if (CommandComment3[0] == 0)
  820.              far_strcpy(CommandComment3,lineptr);
  821.           else
  822.              far_strcpy(CommandComment4,lineptr);
  823.           }
  824.            }
  825.         if (next_line(handle,linebuf,mode) != 0)
  826.            return(-1); /* eof */
  827.         lineptr = linebuf; /* start new line */
  828.         }
  829.      }
  830.       if (*lineptr == '\\'              /* continuation onto next line? */
  831.     && *(lineptr+1) == 0) {
  832.      if (next_line(handle,linebuf,mode) != 0) {
  833.         argerror(cmdbuf);        /* missing continuation */
  834.         return(-1);
  835.         }
  836.      lineptr = linebuf;
  837.      while (*lineptr && *lineptr <= ' ')
  838.         ++lineptr;            /* skip white space @ start next line */
  839.      continue;            /* loop to check end of line again */
  840.      }
  841.       cmdbuf[cmdlen] = *(lineptr++);    /* copy character to command buffer */
  842.       if (++cmdlen >= maxlen) {     /* command too long? */
  843.      argerror(cmdbuf);
  844.      return(-1);
  845.      }
  846.       }
  847. }
  848.  
  849. static int next_line(FILE *handle,char *linebuf,int mode)
  850. {
  851.    int toolssection;
  852.    char tmpbuf[10];
  853.    toolssection = 0;
  854.    while (file_gets(linebuf,512,handle) >= 0) {
  855.       if (mode == 1 && linebuf[0] == '[') {     /* check for [fractint] */
  856.      strncpy(tmpbuf,&linebuf[1],9);
  857.      tmpbuf[9] = 0;
  858.      strlwr(tmpbuf);
  859.      toolssection = strncmp(tmpbuf,"fractint]",9);
  860.      continue;                /* skip tools section heading */
  861.      }
  862.       if (toolssection == 0) return(0);
  863.       }
  864.    return(-1);
  865. }
  866.  
  867. /*
  868.   cmdarg(string,mode) processes a single command-line/command-file argument
  869.     return:
  870.       -1 error, >= 0 ok
  871.       if ok, return value:
  872.     | 1 means fractal parm has been set
  873.     | 2 means 3d parm has been set
  874.     | 4 means 3d=yes specified
  875.     | 8 means reset specified
  876. */
  877.  
  878. /* following gets rid of "too big for optimization" warning */
  879. #ifdef _MSC_VER
  880. #if (_MSC_VER >= 600)
  881. #pragma optimize( "el", off )
  882. #endif
  883. #endif
  884.  
  885. int cmdarg(char *curarg,int mode) /* process a single argument */
  886. {
  887.    char    variable[21];        /* variable name goes here   */
  888.    char    *value;            /* pointer to variable value */
  889.    int       valuelen;            /* length of value         */
  890.    int       numval;            /* numeric value of arg      */
  891. #define NONNUMERIC -32767
  892.    char    charval;            /* first character of arg    */
  893.    int       yesnoval;            /* 0 if 'n', 1 if 'y', -1 if not */
  894.    double  ftemp;
  895.    int       i, j, k, l;
  896.    char    *argptr,*argptr2;
  897.    int       totparms;            /* # of / delimited parms    */
  898.    int       intparms;            /* # of / delimited ints     */
  899.    int       floatparms;            /* # of / delimited floats   */
  900.    int       intval[64];            /* pre-parsed integer parms  */
  901.    double  floatval[16];        /* pre-parsed floating parms */
  902.    char    *floatvalstr[16];        /* pointers to float vals */
  903.    char    tmpc;
  904.    int     lastarg;
  905.    double Xctr, Yctr, Xmagfactor, Rotation, Skew;
  906.    LDBL Magnification;
  907.    bf_t bXctr, bYctr;
  908.  
  909.  
  910.    argptr = curarg;
  911.    while (*argptr) {            /* convert to lower case */
  912.       if (*argptr >= 'A' && *argptr <= 'Z')
  913.      *argptr += 'a' - 'A';
  914.       if (*argptr == '=' && strncmp(curarg,"colors=",7) == 0)
  915.      break;             /* don't convert colors=value */
  916.       ++argptr;
  917.       }
  918.  
  919.    if ((value = strchr(&curarg[1],'=')) != NULL) {
  920.       if ((j = (value++) - curarg) > 1 && curarg[j-1] == ':')
  921.      --j;                /* treat := same as =      */
  922.       }
  923.    else
  924.       value = curarg + (j = strlen(curarg));
  925.    if (j > 20) goto badarg;        /* keyword too long */
  926.    strncpy(variable,curarg,j);        /* get the variable name  */
  927.    variable[j] = 0;            /* truncate variable name */
  928.    valuelen = strlen(value);        /* note value's length    */
  929.    charval = value[0];            /* first letter of value  */
  930.    yesnoval = -1;            /* note yes|no value      */
  931.    if (charval == 'n') yesnoval = 0;
  932.    if (charval == 'y') yesnoval = 1;
  933.  
  934.    argptr = value;
  935.    numval = totparms = intparms = floatparms = 0;
  936.    while (*argptr) {            /* count and pre-parse parms */
  937.       long ll;
  938.       lastarg = 0;
  939.       if ((argptr2 = strchr(argptr,'/')) == NULL) {     /* find next '/' */
  940.      argptr2 = argptr + strlen(argptr);
  941.      *argptr2 = '/';
  942.      lastarg = 1;
  943.      }
  944.       if (totparms == 0) numval = NONNUMERIC;
  945.       i = -1;
  946.       charval = *argptr;            /* first letter of value  */
  947.       if (charval == 'n') yesnoval = 0;    /* allows only ONE y/n param */
  948.       if (charval == 'y') yesnoval = 1;
  949.       j=0;
  950.       if (sscanf(argptr,"%c%c",(char *)&j,&tmpc) > 0    /* NULL entry */
  951.       && ((char)j == '/' || (char)j == '=') && tmpc == '/') {
  952.      j = 0;
  953.      ++floatparms; ++intparms;
  954.      if (totparms < 16) {floatval[totparms] = j; floatvalstr[totparms]="0";}
  955.      if (totparms < 64) intval[totparms] = j;
  956.      if (totparms == 0) numval = j;
  957.      }
  958.       else if (sscanf(argptr,"%ld%c",&ll,&tmpc) > 0       /* got an integer */
  959.     && tmpc == '/') {        /* needs a long int, ll, here for lyapunov */
  960.      ++floatparms; ++intparms;
  961.      if (totparms < 16) {floatval[totparms] = ll; floatvalstr[totparms]=argptr;}
  962.      if (totparms < 64) intval[totparms] = (int)ll;
  963.      if (totparms == 0) numval = (int)ll;
  964.      }
  965. #ifndef XFRACT
  966.       else if (sscanf(argptr,"%lg%c",&ftemp,&tmpc) > 0  /* got a float */
  967. #else
  968.       else if (sscanf(argptr,"%lf%c",&ftemp,&tmpc) > 0  /* got a float */
  969. #endif
  970.          && tmpc == '/') {
  971.      ++floatparms;
  972.      if (totparms < 16) {floatval[totparms] = ftemp;floatvalstr[totparms]=argptr;}
  973.      }
  974.       /* using arbitrary precision and above failed */
  975.       else if ((strlen(argptr) > 513)  /* very long command */ 
  976.                  || (totparms > 0 && floatval[totparms-1] == FLT_MAX 
  977.                  && totparms < 6)) { 
  978.      ++floatparms;
  979.      floatval[totparms] = FLT_MAX;
  980.      floatvalstr[totparms]=argptr;
  981.       } 
  982.       ++totparms;
  983.       argptr = argptr2;                 /* on to the next */
  984.       if (lastarg)
  985.      *argptr = 0;
  986.       else
  987.      ++argptr;
  988.       }
  989.  
  990.    if (mode != 2 || debugflag==110) {
  991.       /* these commands are allowed only at startup */
  992.  
  993.       if (strcmp(variable,s_batch) == 0 ) {     /* batch=?      */
  994.      if (yesnoval < 0) goto badarg;
  995. #ifdef XFRACT
  996.          initmode = yesnoval?0:-1; /* skip credits for batch mode */
  997. #endif
  998.      initbatch = yesnoval;
  999.      return 3;
  1000.      }
  1001.    if (strcmp(variable,"maxhistory") == 0) {       /* maxhistory=? */
  1002.       if(numval == NONNUMERIC)
  1003.      goto badarg;
  1004.       else if(numval < 0 /* || numval > 1000 */) goto badarg;
  1005.       else maxhistory = numval;
  1006.       return 3;
  1007.       }
  1008.  
  1009. #ifndef XFRACT
  1010.       if (strcmp(variable,s_adapter) == 0 ) {   /* adapter==?     */
  1011.          int i, j;
  1012.          char adapter_name[8];      /* entry lenth from VIDEO.ASM */
  1013.          char *adapter_ptr;
  1014.          
  1015.          adapter_ptr = &supervga_list;
  1016.          
  1017.          for(i = 0 ; ; i++) {        /* find the SuperVGA entry */
  1018.              memcpy(adapter_name , adapter_ptr, 8);
  1019.              adapter_name[6] = ' ';
  1020.              for (j = 0; j < 8; j++)
  1021.                  if(adapter_name[j] == ' ')
  1022.                      adapter_name[j] = 0;
  1023.              if (adapter_name[0] == 0) break;  /* end-of-the-list */
  1024.              if (strncmp(value,adapter_name,strlen(adapter_name)) == 0) {
  1025.                 svga_type = i+1;
  1026.                 adapter_ptr[6] = 1;
  1027.                 break;
  1028.                 }
  1029.              adapter_ptr += 8;
  1030.              }
  1031.          if (svga_type != 0) return 3;
  1032.  
  1033.      video_type = 5;            /* assume video=vga */
  1034.      if (strcmp(value,s_egamono) == 0) {
  1035.         video_type = 3;
  1036.         mode7text = 1;
  1037.         }
  1038.      else if (strcmp(value,s_hgc) == 0) {   /* video = hgc */
  1039.         video_type = 1;
  1040.         mode7text = 1;
  1041.         }
  1042.      else if (strcmp(value,s_ega) == 0)     /* video = ega */
  1043.         video_type = 3;
  1044.      else if (strcmp(value,s_cga) == 0)     /* video = cga */
  1045.         video_type = 2;
  1046.      else if (strcmp(value,s_mcga) == 0)    /* video = mcga */
  1047.         video_type = 4;
  1048.      else if (strcmp(value,s_vga) == 0)     /* video = vga */
  1049.         video_type = 5;
  1050.      else
  1051.         goto badarg;
  1052.      return 3;
  1053.      }
  1054.  
  1055.       if (strcmp(variable,s_afi) == 0) {
  1056.        if (strncmp(value,"8514"  ,4) == 0
  1057.            || charval == 'y') ai_8514 = 1; /* set afi flag JCO 4/11/92 */
  1058.        return 3;
  1059.     }
  1060.  
  1061.       if (strcmp(variable,s_textsafe) == 0 ) {  /* textsafe==? */
  1062.      if (first_init) {
  1063.         if (charval == 'n') /* no */
  1064.            textsafe = 2;
  1065.         else if (charval == 'y') /* yes */
  1066.            textsafe = 1;
  1067.         else if (charval == 'b') /* bios */
  1068.            textsafe = 3;
  1069.         else if (charval == 's') /* save */
  1070.            textsafe = 4;
  1071.         else
  1072.            goto badarg;
  1073.         }   
  1074.      return 3;
  1075.      }
  1076.  
  1077.       if (strcmp(variable,s_vesadetect) == 0) {
  1078.      if (yesnoval < 0) goto badarg;
  1079.      vesa_detect = yesnoval;
  1080.      return 3;
  1081.      }
  1082.  
  1083.       if (strcmp(variable,s_biospalette) == 0) {
  1084.          if (yesnoval < 0) goto badarg;
  1085.          bios_palette = yesnoval;
  1086.          return 3;
  1087.          }
  1088.  
  1089.       if (strcmp(variable,s_fpu) == 0) {
  1090.      if (strcmp(value,s_iit) == 0) {
  1091.         fpu = 387;
  1092.         iit = 1;
  1093.         return 0;
  1094.         }
  1095.      if (strcmp(value,s_noiit) == 0) {
  1096.         iit = -2;
  1097.         return 0;
  1098.         }
  1099.      if (strcmp(value,s_387) == 0) {
  1100.         fpu = 387;
  1101.         iit = -2;
  1102.         return 0;
  1103.         }
  1104.      goto badarg;
  1105.      }
  1106. #endif
  1107.  
  1108.       if (strcmp(variable,s_exitnoask) == 0) {
  1109.          if (yesnoval < 0) goto badarg;
  1110.          escape_exit = yesnoval;
  1111.          return 3;
  1112.          }
  1113.  
  1114.       if (strcmp(variable,s_makedoc) == 0) {
  1115.      print_document(*value ? value : "fractint.doc", makedoc_msg_func, 0);
  1116. #ifndef WINFRACT
  1117.      goodbye();
  1118. #endif
  1119.      }
  1120.  
  1121.       } /* end of commands allowed only at startup */
  1122.  
  1123.    if (strcmp(variable,s_reset) == 0) {
  1124.       initvars_fractal();
  1125.  
  1126.       /* PAR release unknown unless specified */
  1127.       if (numval>=0) save_release = numval;
  1128.       else goto badarg;
  1129.       if (save_release == 0)
  1130.          save_release = 1730; /* before start of lyapunov wierdness */
  1131.       return 9;
  1132.       }
  1133.  
  1134.    if (strcmp(variable,s_filename) == 0) {      /* filename=?     */
  1135.       int existdir;
  1136.       if (charval == '.') {
  1137.      if (valuelen > 4) goto badarg;
  1138.      gifmask[0] = '*';
  1139.      gifmask[1] = 0;
  1140.      strcat(gifmask,value);
  1141.      return 0;
  1142.      }
  1143.       if (valuelen > (FILE_MAX_PATH-1)) goto badarg;
  1144.       if (mode == 2 && display3d == 0) /* can't do this in @ command */
  1145.      goto badarg;
  1146.  
  1147.       if((existdir=merge_pathnames(readname, value, mode))==0)
  1148.          showfile = 0;
  1149.       else if(existdir < 0)
  1150.          init_msg(0,variable,value,mode);
  1151.       else
  1152.          extract_filename(browsename,readname);
  1153.       return 3;
  1154.       }
  1155.  
  1156.    if (strcmp(variable,s_video) == 0) {         /* video=? */
  1157.       if (active_system == 0) {
  1158.      if ((k = check_vidmode_keyname(value)) == 0) goto badarg;
  1159.      initmode = -1;
  1160.      for (i = 0; i < MAXVIDEOTABLE; ++i) {
  1161.         if (videotable[i].keynum == k) {
  1162.            initmode = i;
  1163.            break;
  1164.            }
  1165.         }
  1166.      if (initmode == -1) goto badarg;
  1167.      }
  1168.       return 3;
  1169.       }
  1170.  
  1171.    if (strcmp(variable,s_map) == 0 ) {         /* map=, set default colors */
  1172.       int existdir;
  1173.       if (valuelen > (FILE_MAX_PATH-1)) goto badarg;
  1174.       if((existdir=merge_pathnames(MAP_name,value,mode))>0)
  1175.          return 0;    /* got a directory */
  1176.       else if (existdir < 0) {
  1177.          init_msg(0,variable,value,mode);
  1178.          return (0);
  1179.       }   
  1180.       SetColorPaletteName(MAP_name);
  1181.       return 0;
  1182.       }
  1183.  
  1184.    if (strcmp(variable,s_colors) == 0) {       /* colors=, set current colors */
  1185.       if (parse_colors(value) < 0) goto badarg;
  1186.       return 0;
  1187.       }
  1188.  
  1189.    if (strcmp(variable,s_tplus) == 0) {       /* Use the TARGA+ if found? */
  1190.       if (yesnoval < 0) goto badarg;
  1191.       TPlusFlag = yesnoval;
  1192.       return 0;
  1193.       }
  1194.  
  1195.    if (strcmp(variable,s_noninterlaced) == 0) {
  1196.       if (yesnoval < 0) goto badarg;
  1197.       NonInterlaced = yesnoval;
  1198.       return 0;
  1199.       }
  1200.  
  1201.    if (strcmp(variable,s_maxcolorres) == 0) { /* Change default color resolution */
  1202.       if (numval == 1 || numval == 4 || numval == 8 ||
  1203.             numval == 16 || numval == 24) {
  1204.      MaxColorRes = numval;
  1205.      return 0;
  1206.      }
  1207.       goto badarg;
  1208.       }
  1209.  
  1210.    if (strcmp(variable,s_pixelzoom) == 0) {
  1211.       if (numval < 5)
  1212.      PixelZoom = numval;
  1213.       return 0;
  1214.       }
  1215.  
  1216.    /* keep this for backward compatibility */
  1217.    if (strcmp(variable,s_warn) == 0 ) {         /* warn=? */
  1218.       if (yesnoval < 0) goto badarg;
  1219.       overwrite = (char)(yesnoval ^ 1);
  1220.       return 0;
  1221.       }
  1222.    if (strcmp(variable,s_overwrite) == 0 ) {    /* overwrite=? */
  1223.       if (yesnoval < 0) goto badarg;
  1224.       overwrite = (char)yesnoval;
  1225.       return 0;
  1226.       }
  1227.  
  1228.    if (strcmp(variable,s_gif87a) == 0 ) {       /* gif87a=? */
  1229.       if (yesnoval < 0) goto badarg;
  1230.       gif87a_flag = yesnoval;
  1231.       return 0;
  1232.       }
  1233.  
  1234.    if (strcmp(variable,s_dither) == 0 ) {       /* dither=? */
  1235.       if (yesnoval < 0) goto badarg;
  1236.       dither_flag = yesnoval;
  1237.       return 0;
  1238.       }
  1239.  
  1240.    if (strcmp(variable,s_savetime) == 0) {      /* savetime=? */
  1241.       initsavetime = numval;
  1242.       return 0;
  1243.       }
  1244.  
  1245.    if (strcmp(variable,s_autokey) == 0) {       /* autokey=? */
  1246.       if (strcmp(value,s_record)==0)
  1247.      slides=2;
  1248.       else if (strcmp(value,s_play)==0)
  1249.      slides=1;
  1250.       else
  1251.      goto badarg;
  1252.       return 0;
  1253.       }
  1254.  
  1255.    if (strcmp(variable,s_autokeyname) == 0) {   /* autokeyname=? */
  1256.       if(merge_pathnames(autoname, value,mode) < 0)
  1257.          init_msg(0,variable,value,mode);
  1258.       return 0;
  1259.       }
  1260.  
  1261.    if (strcmp(variable,s_type) == 0 ) {         /* type=? */
  1262.       int extra;
  1263.       if (value[valuelen-1] == '*')
  1264.      value[--valuelen] = 0;
  1265.       /* kludge because type ifs3d has an asterisk in front */
  1266.       if(strcmp(value,s_ifs3d)==0)
  1267.          value[3]=0;
  1268.       for (k = 0; fractalspecific[k].name != NULL; k++)
  1269.      if (strcmp(value,fractalspecific[k].name) == 0)
  1270.         break;
  1271.       if (fractalspecific[k].name == NULL) goto badarg;
  1272.       curfractalspecific = &fractalspecific[fractype = k];
  1273.       if (initcorners == 0) {
  1274.      xx3rd = xxmin = curfractalspecific->xmin;
  1275.      xxmax           = curfractalspecific->xmax;
  1276.      yy3rd = yymin = curfractalspecific->ymin;
  1277.      yymax           = curfractalspecific->ymax;
  1278.       }     
  1279.       if (initparams == 0) {
  1280.      for (k = 0; k < 4; ++k) {
  1281.         param[k] = curfractalspecific->paramvalue[k];
  1282.         if(fractype != CELLULAR) /* don't round cellular */
  1283.            roundfloatd(¶m[k]);
  1284.       }
  1285.           if((extra=find_extra_param(fractype)) > -1)
  1286.              for(i=0;i<MAXPARAMS-4;i++) {
  1287.                 param[i+4] = moreparams[extra].paramvalue[i];
  1288.          }
  1289.       }   
  1290.       return 1;
  1291.       }
  1292.    if (strcmp(variable,s_inside) == 0 ) {       /* inside=? */
  1293.       if(strcmp(value,s_zmag)==0)
  1294.      inside = -59;
  1295.       else if(strcmp(value,s_bof60)==0)
  1296.      inside = -60;
  1297.       else if(strcmp(value,s_bof61)==0)
  1298.      inside = -61;
  1299.       else if(strncmp(value,s_epscross,3)==0)
  1300.      inside = -100;
  1301.       else if(strncmp(value,s_startrail,4)==0)
  1302.      inside = -101;
  1303.       else if(strncmp(value,s_period,3)==0)
  1304.      inside = -102;
  1305.       else if(strcmp(value,s_maxiter)==0)
  1306.      inside = -1;
  1307.       else if(numval == NONNUMERIC)
  1308.      goto badarg;
  1309.       else
  1310.      inside = numval;
  1311.       return 1;
  1312.       }
  1313.    if (strcmp(variable,s_fillcolor) == 0 ) {       /* fillcolor */
  1314.       if(strcmp(value,s_normal)==0)
  1315.      fillcolor = -1;
  1316.       else if(numval == NONNUMERIC)
  1317.      goto badarg;
  1318.       else
  1319.      fillcolor = numval;
  1320.       return 1;
  1321.       }
  1322.  
  1323.    if (strcmp(variable,s_finattract) == 0 ) {   /* finattract=? */
  1324.       if (yesnoval < 0) goto badarg;
  1325.       finattract = yesnoval;
  1326.       return 1;
  1327.       }
  1328.  
  1329.    if (strcmp(variable,s_function) == 0) {      /* function=?,? */
  1330.       k = 0;
  1331.       while (*value && k < 4) {
  1332.      if(set_trig_array(k++,value)) goto badarg;
  1333.      if ((value = strchr(value,'/')) == NULL) break;
  1334.      ++value;
  1335.      }
  1336.        functionpreloaded = 1; /* for old bifs  JCO 7/5/92 */
  1337.       return 1;
  1338.       }
  1339.  
  1340.    if (strcmp(variable,s_outside) == 0 ) {      /* outside=? */
  1341.       if(strcmp(value,s_iter)==0)
  1342.      outside = -1;
  1343.       else if(strcmp(value,s_real)==0)
  1344.      outside = -2;
  1345.       else if(strcmp(value,s_imag)==0)
  1346.      outside = -3;
  1347.       else if(strcmp(value,s_mult)==0)
  1348.      outside = -4;
  1349.       else if(strcmp(value,s_sum)==0)
  1350.      outside = -5;
  1351.       else if(strcmp(value,s_atan)==0)
  1352.      outside = -6;
  1353.  
  1354.       else if(numval == NONNUMERIC)
  1355.      goto badarg;
  1356.       else if(numval < -6 || numval > 255) goto badarg;
  1357.       else outside = numval;
  1358.       return 1;
  1359.       }
  1360.  
  1361.    if (strcmp(variable,s_bfdigits) == 0 ) {      /* bfdigits=? */
  1362.       if(numval == NONNUMERIC)
  1363.      goto badarg;
  1364.       else if(numval < 0 || numval > 2000) goto badarg;
  1365.       else bfdigits = numval;
  1366.       return 1;
  1367.       }
  1368.  
  1369.    if (strcmp(variable,s_maxiter) == 0) {       /* maxiter=? */
  1370.       if (floatval[0] < 2) goto badarg;
  1371.       maxit = (long)floatval[0];
  1372.       return 1;
  1373.       }
  1374.  
  1375.    if (strcmp(variable,s_iterincr) == 0)        /* iterincr=? */
  1376.       return 0;
  1377.  
  1378.    if (strcmp(variable,s_passes) == 0) {        /* passes=? */
  1379.       if ( charval != '1' && charval != '2' && charval != '3'
  1380.     && charval != 'g' && charval != 'b'
  1381.     && charval != 't')
  1382.      goto badarg;
  1383.       usr_stdcalcmode = charval;
  1384.       return 1;
  1385.       }
  1386.  
  1387.    if (strcmp(variable,s_cyclelimit) == 0 ) {   /* cyclelimit=? */
  1388.       if (numval <= 1 || numval > 256) goto badarg;
  1389.       initcyclelimit = numval;
  1390.       return 0;
  1391.       }
  1392.  
  1393.    if (strcmp(variable,s_makemig) == 0) {
  1394.        int xmult, ymult;
  1395.        if (totparms < 2) goto badarg;
  1396.        xmult = intval[0];
  1397.        ymult = intval[1];
  1398.        make_mig(xmult, ymult);
  1399. #ifndef WINFRACT
  1400.        exit(0);
  1401. #endif
  1402.        }
  1403.  
  1404.    if (strcmp(variable,s_cyclerange) == 0) {
  1405.       if (totparms < 2) intval[1] = 255;
  1406.       if (totparms < 1) intval[0] = 1;
  1407.       if (totparms != intparms
  1408.     || intval[0] < 0 || intval[1] > 255 || intval[0] > intval[1])
  1409.      goto badarg;
  1410.       rotate_lo = intval[0];
  1411.       rotate_hi = intval[1];
  1412.       return 0;
  1413.       }
  1414.  
  1415.    if (strcmp(variable,s_ranges) == 0) {
  1416.       int i,j,entries,prev;
  1417.       int tmpranges[128];
  1418.       if (totparms != intparms) goto badarg;
  1419.       entries = prev = i = 0;
  1420.       while (i < totparms) {
  1421.      if ((j = intval[i++]) < 0) { /* striping */
  1422.         if ((j = 0-j) < 1 || j >= 16384 || i >= totparms) goto badarg;
  1423.         tmpranges[entries++] = -1; /* {-1,width,limit} for striping */
  1424.         tmpranges[entries++] = j;
  1425.         j = intval[i++];
  1426.         }
  1427.      if (j < prev) goto badarg;
  1428.      tmpranges[entries++] = prev = j;
  1429.      }
  1430.       if (prev == 0) goto badarg;
  1431.       if ((ranges = (int far *)farmemalloc(2L*entries)) == NULL) {
  1432.      static FCODE msg[] = {"Insufficient memory for ranges="};
  1433.      stopmsg(1,msg);
  1434.      return(-1);
  1435.      }
  1436.       rangeslen = entries;
  1437.       for (i = 0; i < rangeslen; ++i)
  1438.      ranges[i] = tmpranges[i];
  1439.       return 1;
  1440.       }
  1441.  
  1442.    if (strcmp(variable,s_savename) == 0) {      /* savename=? */
  1443.       if (valuelen > (FILE_MAX_PATH-1)) goto badarg;
  1444.       if (first_init || mode == 2) {
  1445.          if(merge_pathnames(savename, value, mode) < 0)
  1446.             init_msg(0,variable,value,mode);
  1447.       }
  1448.       return 0;
  1449.       }
  1450.  
  1451.    if (strcmp(variable,s_tempdir) == 0) {      /* tempdir=? */
  1452.       if (valuelen > (FILE_MAX_DIR-1)) goto badarg;
  1453.       if(isadirectory(value) == 0) goto badarg;
  1454.       strcpy(tempdir,value);
  1455.       fix_dirname(tempdir);
  1456.       return 0;
  1457.       }
  1458.  
  1459.    if (strcmp(variable,s_workdir) == 0) {      /* workdir=? */
  1460.       if (valuelen > (FILE_MAX_DIR-1)) goto badarg;
  1461.       if(isadirectory(value) == 0) goto badarg;
  1462.       strcpy(workdir,value);
  1463.       fix_dirname(workdir);
  1464.       return 0;
  1465.       }
  1466.  
  1467.    if (strcmp(variable,s_exitmode) == 0) {      /* exitmode=? */
  1468.       sscanf(value,"%x",&numval);
  1469.       exitmode = (BYTE)numval;
  1470.       return 0;
  1471.       }
  1472.  
  1473.    if (strcmp(variable,s_textcolors) == 0) {
  1474.       parse_textcolors(value);
  1475.       return 0;
  1476.       }
  1477.  
  1478.    if (strcmp(variable,s_potential) == 0) {     /* potential=? */
  1479.       k = 0;
  1480.       while (k < 3 && *value) {
  1481.          if(k==1)
  1482.         potparam[k] = atof(value);
  1483.      else
  1484.         potparam[k] = atoi(value);
  1485.      k++;
  1486.        if ((value = strchr(value,'/')) == NULL) k = 99;
  1487.      ++value;
  1488.      }
  1489.       pot16bit = 0;
  1490.       if (k < 99) {
  1491.      if (strcmp(value,s_16bit)) goto badarg;
  1492.      pot16bit = 1;
  1493.      }
  1494.       return 1;
  1495.       }
  1496.  
  1497.    if (strcmp(variable,s_params) == 0) {        /* params=?,? */
  1498.       if (totparms != floatparms || totparms > MAXPARAMS)
  1499.      goto badarg;
  1500.       initparams = 1;
  1501.       for (k = 0; k < MAXPARAMS; ++k) 
  1502.          param[k] = (k < totparms) ? floatval[k] : 0.0;
  1503.       if(bf_math)
  1504.          for (k = 0; k < MAXPARAMS; k++)
  1505.             floattobf(bfparms[k],param[k]);
  1506.       return 1;
  1507.       }
  1508.  
  1509.    if (strcmp(variable,s_miim) == 0) {        /* miim=?[/?[/?[/?]]] */
  1510.       k = 0;
  1511.       do {
  1512.      if (isdigit(*value) ||
  1513.          *value == '.' || *value == '-' || *value == '+') {
  1514.         if (k >= 4)
  1515.            goto badarg;
  1516.         param[k++] = atof(value);
  1517.      }
  1518.      else if (strncmp(value, JIIMmethod[breadth_first], 
  1519.                  strlen(JIIMmethod[breadth_first])) == 0)
  1520.         major_method = breadth_first;
  1521.      else if (strncmp(value, JIIMmethod[depth_first], 
  1522.                  strlen(JIIMmethod[depth_first])) == 0)
  1523.         major_method = depth_first;
  1524.      else if (strncmp(value, JIIMmethod[random_walk], 
  1525.                  strlen(JIIMmethod[random_walk])) == 0)
  1526.         major_method = random_walk;
  1527. #ifdef RANDOM_RUN
  1528.      else if (strncmp(value, JIIMmethod[random_run], 
  1529.                  strlen(JIIMmethod[random_run])) == 0)
  1530.         major_method = random_run;
  1531. #endif
  1532.      else if (strncmp(value, JIIMleftright[left_first], 
  1533.                  strlen(JIIMleftright[left_first])) == 0)
  1534.         minor_method = left_first;
  1535.      else if (strncmp(value, JIIMleftright[right_first], 
  1536.                  strlen(JIIMleftright[right_first])) == 0)
  1537.         minor_method = right_first;
  1538.      else goto badarg;
  1539.      value = strchr(value, '/');
  1540.       } while (value++);
  1541.       return 1;
  1542.    }
  1543.  
  1544.    if (strcmp(variable,s_initorbit) == 0) {     /* initorbit=?,? */
  1545.       if(strcmp(value,s_pixel)==0)
  1546.      useinitorbit = 2;
  1547.       else {
  1548.      if (totparms != 2 || floatparms != 2) goto badarg;
  1549.      initorbit.x = floatval[0];
  1550.      initorbit.y = floatval[1];
  1551.      useinitorbit = 1;
  1552.      }
  1553.       return 1;
  1554.       }
  1555.  
  1556.    if (strcmp(variable,s_orbitname) == 0 ) {         /* orbitname=? */
  1557.       if(check_orbit_name(value))
  1558.          goto badarg;
  1559.       return 1;
  1560.       }
  1561.    if (strcmp(variable,s_3dmode) == 0 ) {         /* orbitname=? */
  1562.       int i,j;
  1563.       j = -1;
  1564.       for(i=0;i<4;i++)
  1565.          if(strcmp(value,juli3Doptions[i])==0)
  1566.             j = i; 
  1567.       if(j < 0)
  1568.          goto badarg;
  1569.       else
  1570.          juli3Dmode = j;
  1571.       return 1;
  1572.       }
  1573.  
  1574.    if (strcmp(variable,s_julibrot3d) == 0) {       /* julibrot3d=?,?,?,? */
  1575.       if (floatparms != totparms)
  1576.      goto badarg;
  1577.       if(totparms > 0)
  1578.          zdots = (int)floatval[0];
  1579.       if (totparms > 1)
  1580.          originfp = (float)floatval[1];
  1581.       if (totparms > 2)
  1582.          depthfp = (float)floatval[2];
  1583.       if (totparms > 3)
  1584.          heightfp = (float)floatval[3];
  1585.       if (totparms > 4)
  1586.          widthfp = (float)floatval[4];
  1587.       if (totparms > 5)
  1588.          distfp = (float)floatval[5];
  1589.       return 1;
  1590.       }
  1591.  
  1592.    if (strcmp(variable,s_julibroteyes) == 0) {       /* julibroteyes=?,?,?,? */
  1593.       if (floatparms != totparms || totparms != 1)
  1594.      goto badarg;
  1595.       eyesfp =  (float)floatval[0];
  1596.       return 1;
  1597.       }
  1598.  
  1599.    if (strcmp(variable,s_julibrotfromto) == 0) {       /* julibrotfromto=?,?,?,? */
  1600.       if (floatparms != totparms || totparms != 4)
  1601.      goto badarg;
  1602.       mxmaxfp = floatval[0];
  1603.       mxminfp = floatval[1];
  1604.       mymaxfp = floatval[2];
  1605.       myminfp = floatval[3];
  1606.       return 1;
  1607.       }
  1608.  
  1609.    if (strcmp(variable,s_corners) == 0) {       /* corners=?,?,?,? */
  1610.       int dec;
  1611.       if (fractype == CELLULAR)
  1612.           return 1; /* skip setting the corners */
  1613. #if 0 
  1614.       printf("totparms %d floatparms %d\n",totparms, floatparms);
  1615.       getch();
  1616. #endif
  1617.       if (  floatparms != totparms
  1618.             || (totparms != 0 && totparms != 4 && totparms != 6))
  1619.      goto badarg;
  1620.       usemag = 0;
  1621.       if (totparms == 0) return 0; /* turns corners mode on */
  1622.       initcorners = 1;
  1623.       /* good first approx, but dec could be too big */
  1624.       dec = get_max_curarg_len(floatvalstr,totparms) + 1;
  1625.       if((dec > DBL_DIG+1 || debugflag == 3200) && debugflag != 3400) {
  1626.          int old_bf_math;
  1627.  
  1628.          old_bf_math = bf_math;
  1629.          if(!bf_math || dec > decimals)
  1630.             init_bf_dec(dec);
  1631.          if(old_bf_math == 0) {
  1632.             int k;
  1633.             for (k = 0; k < MAXPARAMS; k++)
  1634.                floattobf(bfparms[k],param[k]);
  1635.          }
  1636.          
  1637.          /* xx3rd = xxmin = floatval[0]; */
  1638.          get_bf(bfxmin,floatvalstr[0]);
  1639.          get_bf(bfx3rd,floatvalstr[0]);
  1640.  
  1641.          /* xxmax = floatval[1]; */
  1642.          get_bf(bfxmax,floatvalstr[1]);
  1643.  
  1644.          /* yy3rd = yymin = floatval[2]; */
  1645.          get_bf(bfymin,floatvalstr[2]);
  1646.          get_bf(bfy3rd,floatvalstr[2]);
  1647.  
  1648.          /* yymax = floatval[3]; */
  1649.          get_bf(bfymax,floatvalstr[3]);
  1650.  
  1651.          if (totparms == 6) {
  1652.         /* xx3rd = floatval[4]; */
  1653.             get_bf(bfx3rd,floatvalstr[4]);
  1654.  
  1655.         /* yy3rd = floatval[5]; */
  1656.             get_bf(bfy3rd,floatvalstr[5]);
  1657.          }
  1658.  
  1659.          /* now that all the corners have been read in, get a more */
  1660.          /* accurate value for dec and do it all again             */
  1661.  
  1662.          dec = getprecbf_mag();
  1663.          if (dec < 0)
  1664.             goto badarg;     /* ie: Magnification is +-1.#INF */
  1665.  
  1666.          /* if(dec > decimals) */
  1667.             init_bf_dec(dec);
  1668.  
  1669.          /* now get parameters and corners all over again at new decimal setting */
  1670. #if 0
  1671.          for (k = 0; k < MAXPARAMS; k++)
  1672.             floattobf(bfparms[k],param[k]);
  1673.  
  1674.          /* xx3rd = xxmin = floatval[0]; */
  1675.          get_bf(bfxmin,floatvalstr[0]);
  1676.          get_bf(bfx3rd,floatvalstr[0]);
  1677.  
  1678.          /* xxmax = floatval[1]; */
  1679.          get_bf(bfxmax,floatvalstr[1]);
  1680.  
  1681.          /* yy3rd = yymin = floatval[2]; */
  1682.          get_bf(bfymin,floatvalstr[2]);
  1683.          get_bf(bfy3rd,floatvalstr[2]);
  1684.  
  1685.          /* yymax = floatval[3]; */
  1686.          get_bf(bfymax,floatvalstr[3]);
  1687.  
  1688.          if (totparms == 6) {
  1689.         /* xx3rd = floatval[4]; */
  1690.             get_bf(bfx3rd,floatvalstr[4]);
  1691.  
  1692.         /* yy3rd = floatval[5]; */
  1693.             get_bf(bfy3rd,floatvalstr[5]);
  1694.          }
  1695. #endif         
  1696.       }
  1697.       xx3rd = xxmin = floatval[0];
  1698.       xxmax =          floatval[1];
  1699.       yy3rd = yymin = floatval[2];
  1700.       yymax =          floatval[3];
  1701.  
  1702.       if (totparms == 6) {
  1703.      xx3rd =      floatval[4];
  1704.      yy3rd =      floatval[5];
  1705.      }
  1706.       return 1;
  1707.       }
  1708.  
  1709.    if (strcmp(variable,s_viewwindows) == 0) {  /* viewwindows=?,?,?,?,? */
  1710.       if (totparms > 5 || floatparms-intparms > 2 || intparms > 4)
  1711.      goto badarg;
  1712.       viewwindow = 1;
  1713.       viewreduction = (float)4.2;  /* reset default values */
  1714.       finalaspectratio = screenaspect;
  1715.       viewcrop = 1; /* yes */
  1716.       viewxdots = viewydots = 0;
  1717.  
  1718.       if((totparms > 0) && (floatval[0] > 0.001))
  1719.         viewreduction = (float)floatval[0];
  1720.       if((totparms > 1) && (floatval[1] > 0.001))
  1721.         finalaspectratio = (float)floatval[1];
  1722.       if((totparms > 2) && (yesnoval == 0))
  1723.         viewcrop = yesnoval;
  1724.       if((totparms > 3) && (intval[3] > 0))
  1725.         viewxdots = intval[3];
  1726.       if((totparms == 5) && (intval[4] > 0))
  1727.         viewydots = intval[4];
  1728.       return 1;
  1729.       }
  1730.  
  1731.    if (strcmp(variable,s_centermag) == 0) {    /* center-mag=?,?,?[,?,?,?] */
  1732.       int dec;
  1733.  
  1734.       if ( (totparms != floatparms)
  1735.         || (totparms != 0 && totparms < 3)
  1736.         || (totparms >= 3 && floatval[2] == 0.0))
  1737.      goto badarg;
  1738.       if (fractype == CELLULAR)
  1739.           return 1; /* skip setting the corners */
  1740.       usemag = 1;
  1741.       if (totparms == 0) return 0; /* turns center-mag mode on */
  1742.       initcorners = 1;
  1743.       /* dec = get_max_curarg_len(floatvalstr,totparms); */
  1744. #ifdef USE_LONG_DOUBLE
  1745.       sscanf(floatvalstr[2], "%Lf", &Magnification);
  1746. #else
  1747.       sscanf(floatvalstr[2], "%lf", &Magnification);
  1748. #endif
  1749.  
  1750.       /* I don't know if this is portable, but something needs to */
  1751.       /* be used in case compiler's LDBL_MAX is not big enough    */
  1752.       if (Magnification > LDBL_MAX || Magnification < -LDBL_MAX)
  1753.          goto badarg;     /* ie: Magnification is +-1.#INF */
  1754.  
  1755.       dec = getpower10(Magnification) + 4; /* 4 digits of padding sounds good */
  1756.  
  1757.       if((dec <= DBL_DIG+1 && debugflag != 3200) || debugflag == 3400) { /* rough estimate that double is OK */
  1758.          Xctr = floatval[0];
  1759.          Yctr = floatval[1];
  1760.          /* Magnification = floatval[2]; */  /* already done above */
  1761.          Xmagfactor = 1;
  1762.          Rotation = 0;
  1763.          Skew = 0;
  1764.          if (floatparms > 3)
  1765.             Xmagfactor = floatval[3];
  1766.          if (Xmagfactor == 0)
  1767.             Xmagfactor = 1;
  1768.          if (floatparms > 4)
  1769.             Rotation = floatval[4];
  1770.          if (floatparms > 5)
  1771.             Skew = floatval[5];
  1772.          /* calculate bounds */
  1773.          cvtcorners(Xctr, Yctr, Magnification, Xmagfactor, Rotation, Skew);
  1774.          return 1;
  1775.       }
  1776.       else { /* use arbitrary precision */
  1777.          int old_bf_math;
  1778.          int saved;
  1779.          initcorners = 1;
  1780.          old_bf_math = bf_math;
  1781.          if(!bf_math || dec > decimals)
  1782.             init_bf_dec(dec);
  1783.          if(old_bf_math == 0) {
  1784.             int k;
  1785.             for (k = 0; k < MAXPARAMS; k++)
  1786.                floattobf(bfparms[k],param[k]);
  1787.          }
  1788.          usemag = 1;
  1789.          saved = save_stack();
  1790.          bXctr            = alloc_stack(bflength+2);
  1791.          bYctr            = alloc_stack(bflength+2);
  1792.          /* Xctr = floatval[0]; */
  1793.          get_bf(bXctr,floatvalstr[0]);
  1794.          /* Yctr = floatval[1]; */
  1795.          get_bf(bYctr,floatvalstr[1]);
  1796.          /* Magnification = floatval[2]; */  /* already done above */
  1797.          Xmagfactor = 1;
  1798.          Rotation = 0;
  1799.          Skew = 0;
  1800.          if (floatparms > 3)
  1801.             Xmagfactor = floatval[3];
  1802.          if (Xmagfactor == 0)
  1803.             Xmagfactor = 1;
  1804.          if (floatparms > 4)
  1805.             Rotation = floatval[4];
  1806.          if (floatparms > 5)
  1807.             Skew = floatval[5];
  1808.          /* calculate bounds */
  1809.          cvtcornersbf(bXctr, bYctr, Magnification, Xmagfactor, Rotation, Skew);
  1810.          bfcornerstofloat();
  1811.          restore_stack(saved);
  1812.          return 1;
  1813.       }
  1814.    }
  1815.  
  1816.    if (strcmp(variable,s_invert) == 0) {        /* invert=?,?,? */
  1817.       if (totparms != floatparms || (totparms != 1 && totparms != 3))
  1818.      goto badarg;
  1819.       invert = ((inversion[0] = floatval[0]) != 0.0) ? totparms : 0;
  1820.       if (totparms == 3) {
  1821.      inversion[1] = floatval[1];
  1822.      inversion[2] = floatval[2];
  1823.      }
  1824.       return 1;
  1825.       }
  1826.  
  1827.    if (strcmp(variable,s_olddemmcolors) == 0 ) {     /* olddemmcolors=?   */
  1828.       if (yesnoval < 0) goto badarg;
  1829.       old_demm_colors = yesnoval;
  1830.       return 0;
  1831.       }
  1832.  
  1833.    if (strcmp(variable,s_askvideo) == 0 ) {     /* askvideo=?   */
  1834.       if (yesnoval < 0) goto badarg;
  1835.       askvideo = yesnoval;
  1836.       return 0;
  1837.       }
  1838.  
  1839.    if (strcmp(variable,s_ramvideo) == 0 )       /* ramvideo=?   */
  1840.       return 0; /* just ignore and return, for old time's sake */
  1841.  
  1842.    if (strcmp(variable,s_float) == 0 ) {        /* float=? */
  1843.       if (yesnoval < 0) goto badarg;
  1844.       usr_floatflag = (char)yesnoval;
  1845.       return 3;
  1846.       }
  1847.  
  1848.    if (strcmp(variable,s_biomorph) == 0 ) {     /* biomorph=? */
  1849.       usr_biomorph = numval;
  1850.       return 1;
  1851.       }
  1852.  
  1853.    if (strcmp(variable,s_orbitsave) == 0 ) {     /* orbitsave=? */
  1854.       if (yesnoval < 0) goto badarg;
  1855.       orbitsave = yesnoval;
  1856.       return 1;
  1857.       }
  1858.  
  1859.    if (strcmp(variable,s_bailout) == 0 ) {      /* bailout=? */
  1860.       if (floatval[0] < 1 || floatval[0] > 2100000000L) goto badarg;
  1861.       bailout = (long)floatval[0];
  1862.       return 1;
  1863.       }
  1864.  
  1865.    if (strcmp(variable,s_bailoutest) == 0 ) {   /* bailoutest=? */
  1866.       if     (strcmp(value,s_mod )==0) bailoutest = Mod;
  1867.       else if(strcmp(value,s_real)==0) bailoutest = Real;
  1868.       else if(strcmp(value,s_imag)==0) bailoutest = Imag;
  1869.       else if(strcmp(value,s_or  )==0) bailoutest = Or;
  1870.       else if(strcmp(value,s_and )==0) bailoutest = And;
  1871.       else goto badarg;
  1872.       setbailoutformula(bailoutest);
  1873.       return 1;
  1874.       }
  1875.  
  1876.    if (strcmp(variable,s_symmetry) == 0 ) {     /* symmetry=? */
  1877.       if     (strcmp(value,s_xaxis )==0) forcesymmetry = XAXIS;
  1878.       else if(strcmp(value,s_yaxis )==0) forcesymmetry = YAXIS;
  1879.       else if(strcmp(value,s_xyaxis)==0) forcesymmetry = XYAXIS;
  1880.       else if(strcmp(value,s_origin)==0) forcesymmetry = ORIGIN;
  1881.       else if(strcmp(value,s_pi    )==0) forcesymmetry = PI_SYM;
  1882.       else if(strcmp(value,s_none  )==0) forcesymmetry = NOSYM;
  1883.       else goto badarg;
  1884.       return 1;
  1885.       }
  1886.  
  1887.    if (strcmp(variable,s_printer) == 0 ) {      /* printer=? */
  1888.       if (parse_printer(value) < 0) goto badarg;
  1889.       return 0;
  1890.       }
  1891.  
  1892.    if (strcmp(variable,s_printfile) == 0) {     /* printfile=? */
  1893.       int existdir;
  1894.       if (valuelen > (FILE_MAX_PATH-1)) goto badarg;
  1895.       if((existdir=merge_pathnames(PrintName, value, mode))==0)
  1896.          Print_To_File = 1;
  1897.       else if (existdir < 0)
  1898.          init_msg(0,variable,value,mode);
  1899.       return 0;
  1900.       }
  1901.    if(strcmp(variable,s_rleps) == 0) {
  1902.       Printer_Compress = yesnoval;
  1903.       return(0);
  1904.       }
  1905.    if(strcmp(variable,s_colorps) == 0) {
  1906.       ColorPS = yesnoval;
  1907.       return(0);
  1908.       }
  1909.  
  1910.    if (strcmp(variable,s_epsf) == 0) {          /* EPS type? SWT */
  1911.       Print_To_File = 1;
  1912.       EPSFileType = numval;
  1913.       Printer_Type = 5;
  1914.       if (strcmp(PrintName,s_fract001prn)==0)
  1915.      strcpy(PrintName,"fract001.eps");
  1916.       return 0;
  1917.       }
  1918.  
  1919.    if (strcmp(variable,s_title) == 0) {         /* Printer title block? SWT */
  1920.       if (yesnoval < 0) goto badarg;
  1921.       Printer_Titleblock = yesnoval;
  1922.       return 0;
  1923.       }
  1924.  
  1925.    if (strcmp(variable,s_translate) == 0) {     /* Translate color? SWT */
  1926.       Printer_ColorXlat=0;
  1927.       if (charval == 'y')
  1928.      Printer_ColorXlat=1;
  1929.       else if (numval > 1 || numval < -1)
  1930.      Printer_ColorXlat=numval;
  1931.       return 0;
  1932.       }
  1933.  
  1934.    if (strcmp(variable,s_plotstyle) == 0) {     /* plot style? SWT */
  1935.       Printer_SStyle = numval;
  1936.       return 0;
  1937.       }
  1938.  
  1939.    if (strcmp(variable,s_halftone) == 0) {      /* New halftoning? SWT */
  1940.       if (totparms != intparms) goto badarg;
  1941.       Printer_SetScreen=1;
  1942.       if ((totparms >  0) && ( intval[ 0] >= 0))
  1943.                       Printer_SFrequency = intval[ 0];
  1944.       if ((totparms >  1) && ( intval[ 1] >= 0))
  1945.                       Printer_SAngle     = intval[ 1];
  1946.       if ((totparms >  2) && ( intval[ 2] >= 0))
  1947.                       Printer_SStyle     = intval[ 2];
  1948.       if ((totparms >  3) && ( intval[ 3] >= 0))
  1949.                       Printer_RFrequency = intval[ 3];
  1950.       if ((totparms >  4) && ( intval[ 4] >= 0))
  1951.                       Printer_RAngle     = intval[ 4];
  1952.       if ((totparms >  5) && ( intval[ 5] >= 0))
  1953.                       Printer_RStyle     = intval[ 5];
  1954.       if ((totparms >  6) && ( intval[ 6] >= 0))
  1955.                       Printer_GFrequency = intval[ 6];
  1956.       if ((totparms >  7) && ( intval[ 7] >= 0))
  1957.                       Printer_GAngle     = intval[ 7];
  1958.       if ((totparms >  8) && ( intval[ 8] >= 0))
  1959.                       Printer_GStyle     = intval[ 8];
  1960.       if ((totparms >  9) && ( intval[ 9] >= 0))
  1961.                       Printer_BFrequency = intval[ 9];
  1962.       if ((totparms > 10) && ( intval[10] >= 0))
  1963.                       Printer_BAngle     = intval[10];
  1964.       if ((totparms > 11) && ( intval[11] >= 0))
  1965.                       Printer_BStyle     = intval[11];
  1966.       return 0;
  1967.       }
  1968.  
  1969.    if (strcmp(variable,s_linefeed) == 0) {      /* Use LF for printer */
  1970.       if      (strcmp(value,s_cr)   == 0) Printer_CRLF = 1;
  1971.       else if (strcmp(value,s_lf)   == 0) Printer_CRLF = 2;
  1972.       else if (strcmp(value,s_crlf) == 0) Printer_CRLF = 0;
  1973.       else goto badarg;
  1974.       return 0;
  1975.       }
  1976.  
  1977.    if (strcmp(variable,s_comport) == 0 ) {      /* Set the COM parameters */
  1978.       if ((value=strchr(value,'/')) == NULL) goto badarg;
  1979.       switch (atoi(++value)) {
  1980.      case 110:  l = 0;   break;
  1981.      case 150:  l = 32;  break;
  1982.      case 300:  l = 64;  break;
  1983.      case 600:  l = 96;  break;
  1984.      case 1200: l = 128; break;
  1985.      case 2400: l = 160; break;
  1986.      case 4800: l = 192; break;
  1987.      case 9600:
  1988.      default:   l = 224; break;
  1989.      }
  1990.       if ((value=strchr(value,'/')) == NULL) goto badarg;
  1991.       for (k=0; k < (int)strlen(value); k++) {
  1992.      switch (value[k]) {
  1993.         case '7':  l |= 2;  break;
  1994.         case '8':  l |= 3;  break;
  1995.         case 'o':  l |= 8;  break;
  1996.         case 'e':  l |= 24; break;
  1997.         case '2':  l |= 4;  break;
  1998.         }
  1999.      }
  2000. #ifndef XFRACT
  2001. #ifndef WINFRACT
  2002.       _bios_serialcom(0,numval-1,l);
  2003. #endif
  2004. #endif
  2005.       return 0;
  2006.       }
  2007.  
  2008.    if (strcmp(variable,s_sound) == 0 ) {        /* sound=? */
  2009.       soundflag = 0;
  2010.       if (strncmp(value,"ye",2) == 0) {
  2011.      soundflag = -1;
  2012.      return(0);
  2013.      }
  2014.       if (charval == 'x')
  2015.      soundflag = 1;
  2016.       if (charval == 'y')
  2017.      soundflag = 2;
  2018.       if (charval == 'z')
  2019.      soundflag = 3;
  2020.       return 0;
  2021.       }
  2022.  
  2023.    if (strcmp(variable,s_hertz) == 0) {         /* Hertz=? */
  2024.       if (numval < 200 || numval > 10000) goto badarg;
  2025.       basehertz = numval;
  2026.       return 0;
  2027.       }
  2028.  
  2029.    if (strcmp(variable,s_periodicity) == 0 ) {  /* periodicity=? */
  2030.       usr_periodicitycheck=1;
  2031.       if ((charval == 'n') || (numval == 0))
  2032.      usr_periodicitycheck=0;
  2033.       else if (charval == 'y')
  2034.      usr_periodicitycheck=1;
  2035.       else if (charval == 's')   /* 's' for 'show' */
  2036.      usr_periodicitycheck= -1;
  2037.       else if(numval == NONNUMERIC)
  2038.      goto badarg;
  2039.       else if(numval != 0)
  2040.      usr_periodicitycheck=numval;
  2041.       return 1;
  2042.       }
  2043.  
  2044.    if (strcmp(variable,s_logmap) == 0 ) {       /* logmap=? */
  2045.       if (charval == 'y')
  2046.      LogFlag = 1;                /* palette is logarithmic */
  2047.       else if (charval == 'n')
  2048.      LogFlag = 0;
  2049.       else if (charval == 'o')
  2050.      LogFlag = -1;                /* old log palette */
  2051.       else
  2052.      LogFlag = numval;
  2053.       return 1;
  2054.       }
  2055.  
  2056.    if (strcmp(variable,s_debugflag) == 0
  2057.      || strcmp(variable,s_debug) == 0) {        /* internal use only */
  2058.       debugflag = numval;
  2059.       timerflag = debugflag & 1;        /* separate timer flag */
  2060.       debugflag -= timerflag;
  2061.       return 0;
  2062.       }
  2063.  
  2064.    if (strcmp(variable,s_rseed) == 0) {
  2065.       rseed = numval;
  2066.       rflag = 1;
  2067.       return 1;
  2068.       }
  2069.  
  2070.    if (strcmp(variable,s_orbitdelay) == 0) {
  2071.       orbit_delay = numval;
  2072.       return 0;
  2073.       }
  2074.  
  2075.    if (strcmp(variable,s_showdot) == 0) {
  2076.       showdot=numval;
  2077.       if(showdot<0)
  2078.          showdot=0;
  2079.       return 0;
  2080.       }
  2081.  
  2082.    if (strcmp(variable,s_decomp) == 0) {
  2083.       if (totparms != intparms || totparms < 1) goto badarg;
  2084.       decomp[0] = intval[0];
  2085.       decomp[1] = 0;
  2086.       if (totparms > 1) /* backward compatibility */
  2087.      bailout = decomp[1] = intval[1];
  2088.       return 1;
  2089.       }
  2090.  
  2091.    if (strcmp(variable,s_distest) == 0) {
  2092.       if (totparms != intparms || totparms < 1) goto badarg;
  2093.       usr_distest = intval[0];
  2094.       distestwidth = 71;
  2095.       if (totparms > 1)
  2096.      distestwidth = intval[1];
  2097.       if(totparms > 3 && intval[2] > 0 && intval[3] > 0) {
  2098.          pseudox = intval[2];
  2099.          pseudoy = intval[3];
  2100.       }
  2101.       else
  2102.      pseudox = pseudoy = 0;
  2103.       return 1;
  2104.       }
  2105.  
  2106.    if (strcmp(variable,s_formulafile) == 0) {   /* formulafile=? */
  2107.       if (valuelen > (FILE_MAX_PATH-1)) goto badarg;
  2108.       if(merge_pathnames(FormFileName, value, mode)<0)
  2109.          init_msg(0,variable,value,mode);
  2110.       return 1;
  2111.       }
  2112.  
  2113.    if (strcmp(variable,s_formulaname) == 0) {   /* formulaname=? */
  2114.       if (valuelen > ITEMNAMELEN) goto badarg;
  2115.       strcpy(FormName,value);
  2116.       return 1;
  2117.       }
  2118.  
  2119.    if (strcmp(variable,s_lfile) == 0) {    /* lfile=? */
  2120.       if (valuelen > (FILE_MAX_PATH-1)) goto badarg;
  2121.       if(merge_pathnames(LFileName, value, mode)<0)
  2122.          init_msg(0,variable,value,mode);
  2123.       return 1;
  2124.       }
  2125.  
  2126.    if (strcmp(variable,s_lname) == 0) {
  2127.       if (valuelen > ITEMNAMELEN) goto badarg;
  2128.       strcpy(LName,value);
  2129.       return 1;
  2130.       }
  2131.  
  2132.    if (strcmp(variable,s_ifsfile) == 0) {    /* ifsfile=?? */ 
  2133.       int existdir;
  2134.       if (valuelen > (FILE_MAX_PATH-1)) goto badarg;
  2135.       if((existdir=merge_pathnames(IFSFileName, value, mode))==0)
  2136.          reset_ifs_defn();
  2137.       else if(existdir < 0)
  2138.          init_msg(0,variable,value,mode);
  2139.       return 1;
  2140.       }
  2141.  
  2142.  
  2143.    if (strcmp(variable,s_ifs) == 0
  2144.      || strcmp(variable,s_ifs3d) == 0) {        /* ifs3d for old time's sake */
  2145.       if (valuelen > ITEMNAMELEN) goto badarg;
  2146.       strcpy(IFSName,value);
  2147.       reset_ifs_defn();
  2148.       return 1;
  2149.       }
  2150.  
  2151.    if (strcmp(variable,s_parmfile) == 0) {   /* parmfile=? */ 
  2152.       if (valuelen > (FILE_MAX_PATH-1)) goto badarg;
  2153.       if(merge_pathnames(CommandFile, value, mode)<0)
  2154.          init_msg(0,variable,value,mode);
  2155.       return 1;
  2156.       }
  2157.  
  2158.    if (strcmp(variable,s_stereo) == 0) {        /* stereo=? */
  2159.       if ((numval<0) || (numval>3)) goto badarg;
  2160.       glassestype = numval;
  2161.       return 3;
  2162.       }
  2163.  
  2164.    if (strcmp(variable,s_rotation) == 0) {      /* rotation=?/?/? */
  2165.       if (totparms != 3 || intparms != 3) goto badarg;
  2166.       XROT = intval[0];
  2167.       YROT = intval[1];
  2168.       ZROT = intval[2];
  2169.       return 3;
  2170.       }
  2171.  
  2172.    if (strcmp(variable,s_perspective) == 0) {   /* perspective=? */
  2173.       if (numval == NONNUMERIC) goto badarg;
  2174.       ZVIEWER = numval;
  2175.       return 3;
  2176.       }
  2177.  
  2178.    if (strcmp(variable,s_xyshift) == 0) {       /* xyshift=?/?  */
  2179.       if (totparms != 2 || intparms != 2) goto badarg;
  2180.       XSHIFT = intval[0];
  2181.       YSHIFT = intval[1];
  2182.       return 3;
  2183.       }
  2184.  
  2185.    if (strcmp(variable,s_interocular) == 0) {   /* interocular=? */
  2186.       eyeseparation = numval;
  2187.       return 3;
  2188.       }
  2189.  
  2190.    if (strcmp(variable,s_converge) == 0) {      /* converg=? */
  2191.       xadjust = numval;
  2192.       return 3;
  2193.       }
  2194.  
  2195.    if (strcmp(variable,s_crop) == 0) {          /* crop=? */
  2196.       if (totparms != 4 || intparms != 4
  2197.     || intval[0] < 0 || intval[0] > 100
  2198.     || intval[1] < 0 || intval[1] > 100
  2199.     || intval[2] < 0 || intval[2] > 100
  2200.     || intval[3] < 0 || intval[3] > 100)
  2201.       goto badarg;
  2202.       red_crop_left   = intval[0];
  2203.       red_crop_right  = intval[1];
  2204.       blue_crop_left  = intval[2];
  2205.       blue_crop_right = intval[3];
  2206.       return 3;
  2207.       }
  2208.  
  2209.    if (strcmp(variable,s_bright) == 0) {        /* bright=? */
  2210.       if (totparms != 2 || intparms != 2) goto badarg;
  2211.       red_bright  = intval[0];
  2212.       blue_bright = intval[1];
  2213.       return 3;
  2214.       }
  2215.  
  2216.    if (strcmp(variable,s_xyadjust) == 0) {      /* trans=? */
  2217.       if (totparms != 2 || intparms != 2) goto badarg;
  2218.       xtrans = intval[0];
  2219.       ytrans = intval[1];
  2220.       return 3;
  2221.       }
  2222.  
  2223.    if (strcmp(variable,s_3d) == 0) {            /* 3d=?/?/..    */
  2224.       if(strcmp(value,s_overlay)==0) {
  2225.          yesnoval=1;
  2226.          if(calc_status > -1) /* if no image, treat same as 3D=yes */
  2227.             overlay3d=1;
  2228.       }      
  2229.       else if (yesnoval < 0) goto badarg;
  2230.       display3d = yesnoval;
  2231.       initvars_3d();
  2232.       return (display3d) ? 6 : 2;
  2233.       }
  2234.  
  2235.    if (strcmp(variable,s_sphere) == 0 ) {       /* sphere=? */
  2236.       if (yesnoval < 0) goto badarg;
  2237.       SPHERE = yesnoval;
  2238.       return 2;
  2239.       }
  2240.  
  2241.    if (strcmp(variable,s_scalexyz) == 0) {      /* scalexyz=?/?/? */
  2242.       if (totparms < 2 || intparms != totparms) goto badarg;
  2243.       XSCALE = intval[0];
  2244.       YSCALE = intval[1];
  2245.       if (totparms > 2) ROUGH = intval[2];
  2246.       return 2;
  2247.       }
  2248.  
  2249.    /* "rough" is really scale z, but we add it here for convenience */
  2250.    if (strcmp(variable,s_roughness) == 0) {     /* roughness=?  */
  2251.       ROUGH = numval;
  2252.       return 2;
  2253.       }
  2254.  
  2255.    if (strcmp(variable,s_waterline) == 0) {     /* waterline=?  */
  2256.       if (numval<0) goto badarg;
  2257.       WATERLINE = numval;
  2258.       return 2;
  2259.       }
  2260.  
  2261.    if (strcmp(variable,s_filltype) == 0) {      /* filltype=?   */
  2262.       if (numval < -1 || numval > 6) goto badarg;
  2263.       FILLTYPE = numval;
  2264.       return 2;
  2265.       }
  2266.  
  2267.    if (strcmp(variable,s_lightsource) == 0) {   /* lightsource=?/?/? */
  2268.       if (totparms != 3 || intparms != 3) goto badarg;
  2269.       XLIGHT = intval[0];
  2270.       YLIGHT = intval[1];
  2271.       ZLIGHT = intval[2];
  2272.       return 2;
  2273.       }
  2274.  
  2275.    if (strcmp(variable,s_smoothing) == 0) {     /* smoothing=?  */
  2276.       if (numval<0) goto badarg;
  2277.       LIGHTAVG = numval;
  2278.       return 2;
  2279.       }
  2280.  
  2281.    if (strcmp(variable,s_latitude) == 0) {      /* latitude=?/? */
  2282.       if (totparms != 2 || intparms != 2) goto badarg;
  2283.       THETA1 = intval[0];
  2284.       THETA2 = intval[1];
  2285.       return 2;
  2286.       }
  2287.  
  2288.    if (strcmp(variable,s_longitude) == 0) {     /* longitude=?/? */
  2289.       if (totparms != 2 || intparms != 2) goto badarg;
  2290.       PHI1 = intval[0];
  2291.       PHI2 = intval[1];
  2292.       return 2;
  2293.       }
  2294.  
  2295.    if (strcmp(variable,s_radius) == 0) {        /* radius=? */
  2296.       if (numval < 0) goto badarg;
  2297.       RADIUS = numval;
  2298.       return 2;
  2299.       }
  2300.  
  2301.    if (strcmp(variable,s_transparent) == 0) {   /* transparent? */
  2302.       if (totparms != intparms || totparms < 1) goto badarg;
  2303.       transparent[1] = transparent[0] = intval[0];
  2304.       if (totparms > 1) transparent[1] = intval[1];
  2305.       return 2;
  2306.       }
  2307.  
  2308.    if (strcmp(variable,s_preview) == 0) {       /* preview? */
  2309.       if (yesnoval < 0) goto badarg;
  2310.       preview = (char)yesnoval;
  2311.       return 2;
  2312.       }
  2313.  
  2314.    if (strcmp(variable,s_showbox) == 0) {       /* showbox? */
  2315.       if (yesnoval < 0) goto badarg;
  2316.       showbox = (char)yesnoval;
  2317.       return 2;
  2318.       }
  2319.  
  2320.    if (strcmp(variable,s_coarse) == 0) {        /* coarse=? */
  2321.       if (numval < 3 || numval > 2000) goto badarg;
  2322.       previewfactor = numval;
  2323.       return 2;
  2324.       }
  2325.  
  2326.    if (strcmp(variable,s_randomize) == 0) {     /* RANDOMIZE=? */
  2327.       if (numval<0 || numval>7) goto badarg;
  2328.       RANDOMIZE = numval;
  2329.       return 2;
  2330.       }
  2331.  
  2332.    if (strcmp(variable,s_ambient) == 0) {       /* ambient=? */
  2333.       if (numval<0||numval>100) goto badarg;
  2334.       Ambient = numval;
  2335.       return 2;
  2336.       }
  2337.  
  2338.    if (strcmp(variable,s_haze) == 0) {          /* haze=? */
  2339.       if (numval<0||numval>100) goto badarg;
  2340.       haze = numval;
  2341.       return 2;
  2342.       }
  2343.  
  2344.    if (strcmp(variable,s_fullcolor) == 0) {     /* fullcolor=? */
  2345.       if (yesnoval < 0) goto badarg;
  2346.       Targa_Out = yesnoval;
  2347.       return 2;
  2348.       }
  2349.    if (strcmp(variable,s_targa_out) == 0) {     /* Targa Out? */
  2350.       if (yesnoval < 0) goto badarg;
  2351.       Targa_Out = yesnoval;
  2352.       return 2;
  2353.       }
  2354.  
  2355.    if (strcmp(variable,s_usegrayscale) == 0) {     /* usegrayscale? */
  2356.       if (yesnoval < 0) goto badarg;
  2357.       grayflag = (char)yesnoval;
  2358.       return 2;
  2359.       }
  2360.  
  2361.    if (strcmp(variable,s_monitorwidth) == 0) {     /* monitorwidth=? */
  2362.       if (totparms != 1 || floatparms != 1) goto badarg;
  2363.       AutoStereo_width  = floatval[0];
  2364.       return 2;
  2365.       }
  2366.  
  2367.    if (strcmp(variable,s_targa_overlay) == 0) {         /* Targa Overlay? */
  2368.       if (yesnoval < 0) goto badarg;
  2369.       Targa_Overlay = yesnoval;
  2370.       return 2;
  2371.       }
  2372.  
  2373.    if (strcmp(variable,s_background) == 0) {     /* background=?/? */
  2374.       if (totparms != 3 || intparms != 3) goto badarg;
  2375.                 for (i=0;i<3;i++)
  2376.                         if (intval[i] & 0xff)
  2377.                                 goto badarg;
  2378.       back_color[0] = (BYTE)intval[0];
  2379.       back_color[1] = (BYTE)intval[1];
  2380.       back_color[2] = (BYTE)intval[2];
  2381.       return 2;
  2382.       }
  2383.  
  2384.    if (strcmp(variable,s_lightname) == 0) {     /* lightname=?   */
  2385.       if (valuelen > (FILE_MAX_PATH-1)) goto badarg;
  2386.       if (first_init || mode == 2)
  2387.      strcpy(light_name,value);
  2388.       return 0;
  2389.       }
  2390.  
  2391.    if (strcmp(variable,s_ray) == 0) {           /* RAY=? */
  2392.       if (numval < 0 || numval > 6) goto badarg;
  2393.       RAY = numval;
  2394.       return 2;
  2395.       }
  2396.  
  2397.    if (strcmp(variable,s_brief) == 0) {         /* BRIEF? */
  2398.       if (yesnoval < 0) goto badarg;
  2399.       BRIEF = yesnoval;
  2400.       return 2;
  2401.       }
  2402.  
  2403.    if (strcmp(variable,s_release) == 0) {       /* release */
  2404.       if (numval < 0) goto badarg;
  2405.  
  2406.       save_release = numval;
  2407.       return 2;
  2408.       }
  2409.  
  2410.  
  2411. badarg:
  2412.    argerror(curarg);
  2413.    return(-1);
  2414.  
  2415. }
  2416.  
  2417. #ifdef _MSC_VER
  2418. #if (_MSC_VER >= 600)
  2419. #pragma optimize( "el", on )
  2420. #endif
  2421. #endif
  2422.  
  2423. /* Some routines broken out of above so compiler doesn't run out of heap: */
  2424.  
  2425. static void parse_textcolors(char *value)
  2426. {
  2427.    int i,j,k,hexval;
  2428.    if (strcmp(value,s_mono) == 0) {
  2429.       for (k = 0; k < sizeof(txtcolor); ++k)
  2430.      txtcolor[k] = BLACK*16+WHITE;
  2431.    /* C_HELP_CURLINK = C_PROMPT_INPUT = C_CHOICE_CURRENT = C_GENERAL_INPUT
  2432.              = C_AUTHDIV1 = C_AUTHDIV2 = WHITE*16+BLACK; */
  2433.       txtcolor[6] = txtcolor[12] = txtcolor[13] = txtcolor[14] = txtcolor[20]
  2434.           = txtcolor[27] = txtcolor[28] = WHITE*16+BLACK;
  2435.       /* C_TITLE = C_HELP_HDG = C_HELP_LINK = C_PROMPT_HI = C_CHOICE_SP_KEYIN
  2436.          = C_GENERAL_HI = C_DVID_HI = C_STOP_ERR
  2437.          = C_STOP_INFO = BLACK*16+L_WHITE; */
  2438.       txtcolor[0] = txtcolor[2] = txtcolor[5] = txtcolor[11] = txtcolor[16]
  2439.           = txtcolor[17] = txtcolor[22] = txtcolor[24]
  2440.           = txtcolor[25] = BLACK*16+L_WHITE;
  2441.       }
  2442.    else {
  2443.       k = 0;
  2444.       while ( k < sizeof(txtcolor)) {
  2445.      if (*value == 0) break;
  2446.      if (*value != '/') {
  2447.         sscanf(value,"%x",&hexval);
  2448.         i = (hexval / 16) & 7;
  2449.         j = hexval & 15;
  2450.         if (i == j || (i == 0 && j == 8)) /* force contrast */
  2451.            j = 15;
  2452.         txtcolor[k] = (BYTE)(i * 16 + j);
  2453.         if ((value = strchr(value,'/')) == NULL) break;
  2454.         }
  2455.      ++value;
  2456.      ++k;
  2457.      }
  2458.       }
  2459. }
  2460.  
  2461. static int parse_colors(char *value)
  2462. {
  2463.    int i,j,k;
  2464.    if (*value == '@') {
  2465.       if(merge_pathnames(MAP_name,&value[1],3)<0)
  2466.          init_msg(0,"",&value[1],3);
  2467.       if (strlen(value) > FILE_MAX_PATH || ValidateLuts(MAP_name) != 0) 
  2468.          goto badcolor;
  2469.       if (display3d) {
  2470.         mapset = 1;
  2471.         }
  2472.       else {
  2473.         if(merge_pathnames(colorfile,&value[1],3)<0)
  2474.           init_msg(0,"",&value[1],3);
  2475.         colorstate = 2;
  2476.         }
  2477.       }
  2478.    else {
  2479.       int smooth;
  2480.       i = smooth = 0;
  2481.       while (*value) {
  2482.      if (i >= 256) goto badcolor;
  2483.      if (*value == '<') {
  2484.         if (i == 0 || smooth
  2485.           || (smooth = atoi(value+1)) < 2
  2486.           || (value = strchr(value,'>')) == NULL)
  2487.            goto badcolor;
  2488.         i += smooth;
  2489.         ++value;
  2490.         }
  2491.      else {
  2492.         for (j = 0; j < 3; ++j) {
  2493.            if ((k = *(value++)) < '0')  goto badcolor;
  2494.            else if (k <= '9')       k -= '0';
  2495.            else if (k < 'A')            goto badcolor;
  2496.            else if (k <= 'Z')       k -= ('A'-10);
  2497.            else if (k < '_' || k > 'z') goto badcolor;
  2498.            else            k -= ('_'-36);
  2499.            dacbox[i][j] = (BYTE)k;
  2500.            if (smooth) {
  2501.           int start,spread,cnum;
  2502.           start = i - (spread = smooth + 1);
  2503.           cnum = 0;
  2504.           if ((k - (int)dacbox[start][j]) == 0) {
  2505.              while (++cnum < spread)
  2506.             dacbox[start+cnum][j] = (BYTE)k;
  2507.              }
  2508.           else {
  2509.              while (++cnum < spread)
  2510.             dacbox[start+cnum][j] =
  2511.                (BYTE)(( cnum *dacbox[i][j]
  2512.                + (i-(start+cnum))*dacbox[start][j]
  2513.                + spread/2 )
  2514.                / spread);
  2515.              }
  2516.           }
  2517.            }
  2518.         smooth = 0;
  2519.         ++i;
  2520.         }
  2521.      }
  2522.       if (smooth) goto badcolor;
  2523.       while (i < 256)  { /* zap unset entries */
  2524.      dacbox[i][0] = dacbox[i][1] = dacbox[i][2] = 40;
  2525.      ++i;
  2526.      }
  2527.       colorstate = 1;
  2528.       }
  2529.    colorpreloaded = 1;
  2530.    memcpy(olddacbox,dacbox,256*3);
  2531.    return(0);
  2532. badcolor:
  2533.    return(-1);
  2534. }
  2535.  
  2536. static int parse_printer(char *value)
  2537. {
  2538.    int k;
  2539.    if (value[0]=='h' && value[1]=='p')
  2540.       Printer_Type=1;                 /* HP LaserJet           */
  2541.    if (value[0]=='i' && value[1]=='b')
  2542.       Printer_Type=2;                 /* IBM Graphics           */
  2543.    if (value[0]=='e' && value[1]=='p')
  2544.       Printer_Type=2;                 /* Epson (model?)           */
  2545.    if (value[0]=='c' && value[1]=='o')
  2546.       Printer_Type=3;                 /* Star (Epson-Comp?) color */
  2547.    if (value[0]=='p') {
  2548.       if (value[1]=='a')
  2549.      Printer_Type=4;             /* HP Paintjet (color)    */
  2550.       if ((value[1]=='o' || value[1]=='s')) {
  2551.      Printer_Type=5;             /* PostScript  SWT */
  2552.      if (value[2]=='h' || value[2]=='l')
  2553.         Printer_Type=6;
  2554.      }
  2555.       if (value[1]=='l')
  2556.      Printer_Type=7;             /* HP Plotter (semi-color) */
  2557.       }
  2558.    if (Printer_Type == 1)             /* assume low resolution */
  2559.       Printer_Resolution = 75;
  2560.    else
  2561.       Printer_Resolution = 60;
  2562.    if (EPSFileType > 0)              /* EPS save - force type 5 */
  2563.       Printer_Type = 5;
  2564.    if ((Printer_Type == 5) || (Printer_Type == 6))
  2565.       Printer_Resolution = 150;          /* PostScript def. res. */
  2566.    if ((value=strchr(value,'/')) != NULL) {
  2567.       if ((k=atoi(++value)) >= 0) Printer_Resolution=k;
  2568.       if ((value=strchr(value,'/')) != NULL) {
  2569.      if ((k=atoi(++value))> 0) LPTNumber = k;
  2570.      if (k < 0) {
  2571.         Print_To_File = 1;
  2572.         LPTNumber = 1;
  2573.         }
  2574.      }
  2575.       }
  2576.    return(0);
  2577. }
  2578.  
  2579.  
  2580.  
  2581. static void argerror(char *badarg)    /* oops. couldn't decode this */
  2582. {
  2583.    static FCODE argerrmsg1[]={"\
  2584. Oops. I couldn't understand the argument:\n  "};
  2585.    static FCODE argerrmsg2[]={"\n\n\
  2586. (see the Startup Help screens or documentation for a complete\n\
  2587.  argument list with descriptions)"};
  2588.    char msg[300];
  2589.    if (strlen(badarg) > 70) badarg[70] = 0;
  2590.    if (active_system == 0 /* DOS */
  2591.      && first_init)      /* & this is 1st call to cmdfiles */
  2592. #ifndef XFRACT
  2593.       sprintf(msg,"%Fs%s%Fs",(char far *)argerrmsg1,badarg,(char far *)argerrmsg2);
  2594.    else
  2595.       sprintf(msg,"%Fs%s",(char far *)argerrmsg1,badarg);
  2596. #else
  2597.       sprintf(msg,"%s%s%s",argerrmsg1,badarg,argerrmsg2);
  2598.    else
  2599.       sprintf(msg,"%s%s",argerrmsg1,badarg);
  2600. #endif
  2601.    stopmsg(0,msg);
  2602. }
  2603.  
  2604. void set_3d_defaults()
  2605. {
  2606.    ROUGH     = 30;
  2607.    WATERLINE = 0;
  2608.    ZVIEWER   = 0;
  2609.    XSHIFT    = 0;
  2610.    YSHIFT    = 0;
  2611.    xtrans    = 0;
  2612.    ytrans    = 0;
  2613.    LIGHTAVG  = 0;
  2614.    Ambient   = 20;
  2615.    RANDOMIZE = 0;
  2616.    haze      = 0;
  2617.    back_color[0] = 51; back_color[1] = 153; back_color[2] = 200;
  2618.    if(SPHERE) {
  2619.       PHI1    =  180;
  2620.       PHI2    =  0;
  2621.       THETA1    =  -90;
  2622.       THETA2    =  90;
  2623.       RADIUS    =  100;
  2624.       FILLTYPE    = 2;
  2625.       XLIGHT    = 1;
  2626.       YLIGHT    = 1;
  2627.       ZLIGHT    = 1;
  2628.       }
  2629.    else {
  2630.       XROT    = 60;
  2631.       YROT    = 30;
  2632.       ZROT    = 0;
  2633.       XSCALE    = 90;
  2634.       YSCALE    = 90;
  2635.       FILLTYPE    = 0;
  2636.       if (active_system != 0)
  2637.      FILLTYPE = 2;
  2638.       XLIGHT    = 1;
  2639.       YLIGHT    = -1;
  2640.       ZLIGHT    = 1;
  2641.       }
  2642. }
  2643.  
  2644. /* copy a big number from a string, up to slash */
  2645. static int get_bf(bf_t bf, char *curarg)
  2646. {
  2647.    char *s;
  2648.    s=strchr(curarg,'/');
  2649.    if(s)
  2650.       *s = 0;
  2651.    strtobf(bf,curarg);
  2652.    if(s)
  2653.       *s = '/';
  2654.    return(0);       
  2655. }
  2656.  
  2657. /* Get length of current args */
  2658. int get_curarg_len(char *curarg)
  2659. {
  2660.    int len;
  2661.    char *s;
  2662.    s=strchr(curarg,'/');
  2663.    if(s)
  2664.       *s = 0;
  2665.    len = strlen(curarg);
  2666.    if(s)
  2667.       *s = '/';
  2668.    return(len);       
  2669. }
  2670.  
  2671. /* Get max length of current args */
  2672. int get_max_curarg_len(char *floatvalstr[], int totparms)
  2673. {
  2674.    int i,tmp,max_str;
  2675.    max_str = 0;
  2676.    for(i=0;i<totparms;i++)
  2677.       if((tmp=get_curarg_len(floatvalstr[i])) > max_str)
  2678.          max_str = tmp;
  2679.    return(max_str);
  2680. }
  2681.  
  2682. /* mode = 0 command line @filename         */
  2683. /*        1 sstools.ini                   */
  2684. /*        2 <@> command after startup      */
  2685. /*        3 command line @filename/setname */
  2686. /* this is like stopmsg() but can be used in cmdfiles()      */
  2687. /* call with NULL for badfilename to get pause for getakey() */
  2688. int init_msg(int flags,char *cmdstr,char far *badfilename,int mode)
  2689. {
  2690.    static char far *modestr[4] =
  2691.        {s_commandline,s_sstoolsini,s_at_cmd,s_at_cmd};
  2692.    static FCODE diags[] = 
  2693.        {"Fractint found the following problems when parsing commands: "};
  2694.    char msg[256];
  2695.    char cmd[80];
  2696.    static int row = 1;
  2697.  
  2698.    if (initbatch == 1) { /* in batch mode */
  2699.       if(badfilename)
  2700.          /* uncomment next if wish to cause abort in batch mode for 
  2701.             errors in CMDFILES.C such as parsing SSTOOLS.INI */ 
  2702.          /* initbatch = 4; */ /* used to set errorlevel */
  2703.       return (-1);
  2704.    }
  2705.    strncpy(cmd,cmdstr,30);
  2706.    cmd[29] = 0;
  2707.    
  2708.    if(*cmd)
  2709.       strcat(cmd,"=");
  2710.    if(badfilename)
  2711. #ifndef XFRACT
  2712.       sprintf(msg,"Can't find %s%Fs, please check %Fs",cmd,badfilename,modestr[mode]);
  2713. #else
  2714.       sprintf(msg,"Can't find %s%s, please check %s",cmd,badfilename,modestr[mode]);
  2715. #endif
  2716.    if (active_system == 0 /* DOS */
  2717.      && first_init) {       /* & cmdfiles hasn't finished 1st try */
  2718.       if(row == 1 && badfilename) {
  2719.          setvideotext();
  2720.          putstring(0,0,15,diags);
  2721.       }
  2722.       if(badfilename)
  2723.          putstring(row++,0,7,msg);
  2724.       else if(row > 1){
  2725.          putstring(++row,0,15,s_escapetoabort);
  2726.          movecursor(row+1,0);
  2727.          /*
  2728.          if(getakeynohelp()==27)
  2729.             goodbye();
  2730.          */
  2731.          dopause(2);  /* defer getakeynohelp until after parseing */
  2732.       }   
  2733.    }   
  2734.    else if(badfilename)
  2735.       stopmsg(flags,msg);
  2736.    return(0);   
  2737. }
  2738.  
  2739. /* defer pause until after parsing so we know if in batch mode */
  2740. void dopause(int action)
  2741. {
  2742.    static unsigned char needpause = 0;
  2743.    switch(action)
  2744.    {
  2745.    case 0:
  2746.       if(initbatch == 0)
  2747.       {
  2748.          if(needpause == 1)
  2749.             getakey();
  2750.          else if (needpause == 2)
  2751.             if(getakeynohelp() == ESC)
  2752.                goodbye();
  2753.       }
  2754.       needpause = 0;      
  2755.       break;
  2756.    case 1:
  2757.    case 2:
  2758.       needpause = (char)action;
  2759.       break;
  2760.    default:
  2761.       break;         
  2762.    }
  2763. }
  2764.